Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ 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.
In non-regex mode, it also replaces JSON-escaped versions of the search
string, such as `http:\/\/example.com` when searching for
`http://example.com`.
Comment thread
swissspidy marked this conversation as resolved.

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

# Replace a URL in plain text and JSON-escaped data
$ wp search-replace 'https://example.com' 'https://example.test'

# Bash script: Search/replace production to development url (multisite compatible)
#!/bin/bash
if $(wp --url=http://example.com core is-installed --network); then
Expand Down
6 changes: 6 additions & 0 deletions src/Search_Replace_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class Search_Replace_Command extends WP_CLI_Command {
*
* Search/replace intelligently handles PHP serialized data, and does not
* change primary key values.
* In non-regex mode, it also replaces JSON-escaped versions of the search
* string, such as `http:\/\/example.com` when searching for
* `http://example.com`.
Comment on lines +142 to +144
*
* Tables without a primary key are skipped. To check whether a table has a
* primary key, run `wp db query 'DESCRIBE <table>'` and look for 'PRI' in
Expand Down Expand Up @@ -278,6 +281,9 @@ class Search_Replace_Command extends WP_CLI_Command {
* # Use precise mode for complex serialized data
* $ wp search-replace 'oldurl.com' 'newurl.com' --precise
*
* # Replace a URL in plain text and JSON-escaped data
* $ wp search-replace 'https://example.com' 'https://example.test'
*
Comment on lines +284 to +286
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing about this example really says JSON, it doesn't provide any additional value over the very first example above.

Let's remove.

* # Bash script: Search/replace production to development url (multisite compatible)
* #!/bin/bash
* if $(wp --url=http://example.com core is-installed --network); then
Expand Down
Loading