Skip to content

Commit 38fd251

Browse files
committed
Clarify JSON-escaped search-replace behavior
1 parent 3db2bb1 commit 38fd251

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ multisite, this will just be the tables for the current site unless
2222

2323
Search/replace intelligently handles PHP serialized data, and does not
2424
change primary key values.
25+
In non-regex mode, it also replaces JSON-escaped versions of the search
26+
string, such as `http:\/\/example.com` when searching for
27+
`http://example.com`.
2528

2629
Tables without a primary key are skipped. To check whether a table has a
2730
primary key, run `wp db query 'DESCRIBE <table>'` and look for 'PRI' in
@@ -161,6 +164,9 @@ the Key column.
161164
# Use precise mode for complex serialized data
162165
$ wp search-replace 'oldurl.com' 'newurl.com' --precise
163166

167+
# Replace a URL in plain text and JSON-escaped data
168+
$ wp search-replace 'https://example.com' 'https://example.test'
169+
164170
# Bash script: Search/replace production to development url (multisite compatible)
165171
#!/bin/bash
166172
if $(wp --url=http://example.com core is-installed --network); then

src/Search_Replace_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ class Search_Replace_Command extends WP_CLI_Command {
139139
*
140140
* Search/replace intelligently handles PHP serialized data, and does not
141141
* change primary key values.
142+
* In non-regex mode, it also replaces JSON-escaped versions of the search
143+
* string, such as `http:\/\/example.com` when searching for
144+
* `http://example.com`.
142145
*
143146
* Tables without a primary key are skipped. To check whether a table has a
144147
* primary key, run `wp db query 'DESCRIBE <table>'` and look for 'PRI' in
@@ -278,6 +281,9 @@ class Search_Replace_Command extends WP_CLI_Command {
278281
* # Use precise mode for complex serialized data
279282
* $ wp search-replace 'oldurl.com' 'newurl.com' --precise
280283
*
284+
* # Replace a URL in plain text and JSON-escaped data
285+
* $ wp search-replace 'https://example.com' 'https://example.test'
286+
*
281287
* # Bash script: Search/replace production to development url (multisite compatible)
282288
* #!/bin/bash
283289
* if $(wp --url=http://example.com core is-installed --network); then

0 commit comments

Comments
 (0)