diff --git a/README.md b/README.md index f2905ae0..0ae9474e 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,10 @@ multisite, this will just be the tables for the current site unless Search/replace intelligently handles PHP serialized data, and does not change primary key values. -Note: URLs stored inside JSON-encoded data (such as block attributes or -form configurations) often have forward slashes escaped with backslashes -(e.g. `https:\/\/example.com`). Standard search/replace with unescaped -URLs will not match these. To replace URLs in JSON-encoded strings, run -an additional search/replace with escaped slashes (e.g. -`wp search-replace 'https:\/\/example.com' 'https:\/\/example.test'`). +The JSON-encoded form of the search string is replaced as well, so a +search for `https://example.com` also matches `https:\/\/example.com` +in JSON stored in the database. This does not apply with `--regex`, +where the pattern itself has to account for escaped slashes. Tables without a primary key are skipped. To check whether a table has a primary key, run `wp db query 'DESCRIBE '` and look for 'PRI' in @@ -151,9 +149,6 @@ the Key column. # Search and replace but skip one column $ wp search-replace 'http://example.test' 'http://example.com' --skip-columns=guid - # Search/replace JSON-encoded URLs (where forward slashes are escaped with backslashes) - $ wp search-replace 'https:\/\/example.com' 'https:\/\/example.test' - # Run search/replace operation but dont save in database $ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run diff --git a/src/Search_Replace_Command.php b/src/Search_Replace_Command.php index 10bd575c..b65b884c 100644 --- a/src/Search_Replace_Command.php +++ b/src/Search_Replace_Command.php @@ -140,12 +140,10 @@ class Search_Replace_Command extends WP_CLI_Command { * Search/replace intelligently handles PHP serialized data, and does not * change primary key values. * - * Note: URLs stored inside JSON-encoded data (such as block attributes or - * form configurations) often have forward slashes escaped with backslashes - * (e.g. `https:\/\/example.com`). Standard search/replace with unescaped - * URLs will not match these. To replace URLs in JSON-encoded strings, run - * an additional search/replace with escaped slashes (e.g. - * `wp search-replace 'https:\/\/example.com' 'https:\/\/example.test'`). + * The JSON-encoded form of the search string is replaced as well, so a + * search for `https://example.com` also matches `https:\/\/example.com` + * in JSON stored in the database. This does not apply with `--regex`, + * where the pattern itself has to account for escaped slashes. * * Tables without a primary key are skipped. To check whether a table has a * primary key, run `wp db query 'DESCRIBE
'` and look for 'PRI' in @@ -268,9 +266,6 @@ class Search_Replace_Command extends WP_CLI_Command { * # Search and replace but skip one column * $ wp search-replace 'http://example.test' 'http://example.com' --skip-columns=guid * - * # Search/replace JSON-encoded URLs (where forward slashes are escaped with backslashes) - * $ wp search-replace 'https:\/\/example.com' 'https:\/\/example.test' - * * # Run search/replace operation but dont save in database * $ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run *