-
Notifications
You must be signed in to change notification settings - Fork 1k
Replace all occurrences in large search-replace operations #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace all occurrences in large search-replace operations #473
Conversation
|
The test currently fails because the test suite doesn't support nested calls, like We use the |
|
I suppose it wouldn't be impossible to devise a regex that replaces this: with this: and get rid of the workaround. |
|
Or we could just set |
|
See #475 |
The wp aliases in my PATH made me oblivious before...
In this case the current code works, but alternatives I was considering might not. Also removed the small test - that case is already covered.
|
I'm still not convinced there's a bug. In https://travis-ci.org/wp-cli/wp-cli/builds/7552302 the test fails because STDOUT also contains a confirmation message: |
You mean there's some edge case where the command wouldn't work correctly? Please explain. |
|
The test that fails makes 1000 replacements in the guid column, changing http://example.com to http://newdomain.com. The bug happens when the iterator then tries to get the next chunk using |
|
The tests for this are slow. Would it be worth making chunk size a parameter to facilitate smaller tests? |
Now I get it. Thanks!
I would prefer not to make it an explicit parameter. |
php/commands/search-replace.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query string is duplicated (once here and once at line 76). You should move it to a helper method.
Or maybe we could add an extra parameter to Iterators\Table to make it have this behaviour (repeat the same query until there are no more results).
|
I took a stab at handling this in the iterator instead. |
|
The code looks solid now. Thanks! |
Replace all occurrences in large search-replace operations
|
Man, those tests really are slow. |
When there are more than 1000 replacements to be done and the replacement string does not contain the search string, not all replacements are made.