wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

Fix offset handling when doing chunked replaces #162

Closed schlessera closed 3 years ago

schlessera commented 3 years ago

In #153 the --precise queries were chunked to avoid loading the entire DB into memory and thus risking OOM issues.

However, the replacement is happening within each chunk, which breaks the $offset handling, causing every second chunk to be missed. This makes it necessary to run a query multiple times to ensure all occurrences are replaced.

This PR defers the actual updates until after the full search. This is still worse in terms of memory management that completely isolated chunking, but it should still be an overall improvement while making the replacements in a reliable way.

Fixes #157