Run wp cache flush and wp search-replace on multisite even when site isn't found#4527
Run wp cache flush and wp search-replace on multisite even when site isn't found#4527danielbachhuber merged 5 commits intomasterfrom
wp cache flush and wp search-replace on multisite even when site isn't found#4527Conversation
Avoids annoying "Error: Site not found" failure when an old host value may be stored in the lookup cache. Because flushing the cache is a global operation (not site-specific), it's safe to run as long as the cache has been initialized. In considering all possible implementations (e.g. registering a new `@when` invoke, etc.), this approach seems to have the least possible impact.
wp cache flush on multisite even when site isn't foundwp cache flush and wp search-replace on multisite even when site isn't found
| """ | ||
| And the return code should be 1 | ||
|
|
||
| When I run `wp search-replace foo bar --network` |
There was a problem hiding this comment.
Noticed that if you change this to something that will get replaced, eg wp search-replace example bar --network then Search_Command will throw a PHP fatal as it relies on the WP functions esc_sql() (and like_escape()) being available so will need to shim these in Search_Command.
There was a problem hiding this comment.
@gitlost But Search_Command runs after WordPress has loaded, which means WordPress would be loaded for wp search-replace?
There was a problem hiding this comment.
I haven't followed the logic but it's probably some multisite peculiarity in loading - if you make that change to the test do you see the fatal?
There was a problem hiding this comment.
They're trivial functions so I'll do a PR on search-command with them copied in...
There was a problem hiding this comment.
I think we can / should accommodate in Runner. Doing so now.
There was a problem hiding this comment.
Cool. (Shimming those functions might still be something to consider as it leaves search-replace only dependent on $wpdb, which could be useful.)
|
I think that Other than that, ready to merge. |

Avoids annoying "Error: Site not found" failure when you'd expect these commands to work.
Because these operations can be global (
cache flushalways,search-replacewith specific arguments), they're safe to run as long as the cache / database have been initialized.In considering all possible implementations (e.g. registering a new
@wheninvoke, etc.), this approach seems to have the least possible impact.Fixes wp-cli/cache-command#17
Fixes wp-cli/search-replace-command#41