You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
are supported to apply the inclusion to a specific table only.
83
89
84
90
[--precise]
85
91
Force the use of PHP (instead of SQL) for all columns. By default, the command
@@ -193,6 +199,10 @@ Want to contribute a new feature? Please first [open a new issue](https://github
193
199
194
200
Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.
195
201
202
+
### License
203
+
204
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
205
+
196
206
## Support
197
207
198
208
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
Scenario: Search and replace handles JSON-encoded URLs in post content
281
+
Given a WP install
282
+
283
+
When I run `wp post create --post_content='{"src":"http:\/\/example.com\/wp-content\/uploads\/fonts\/test.woff2","fontWeight":"400"}' --post_status=publish --porcelain`
284
+
Then save STDOUT as {POST_ID}
285
+
286
+
When I run `wp post get {POST_ID} --field=post_content`
287
+
Then STDOUT should contain:
288
+
"""
289
+
http:\/\/example.com
290
+
"""
291
+
292
+
When I run `wp search-replace 'http://example.com''http://newdomain.com' wp_posts --include-columns=post_content`
293
+
Then STDOUT should be a table containing rows:
294
+
| Table | Column | Replacements | Type |
295
+
| wp_posts | post_content | 1 | SQL |
296
+
297
+
When I run `wp post get {POST_ID} --field=post_content`
298
+
Then STDOUT should contain:
299
+
"""
300
+
http:\/\/newdomain.com
301
+
"""
302
+
And STDOUT should not contain:
303
+
"""
304
+
http:\/\/example.com
305
+
"""
306
+
307
+
When I run `wp search-replace 'http://newdomain.com''http://example.com' wp_posts --include-columns=post_content --precise`
308
+
Then STDOUT should be a table containing rows:
309
+
| Table | Column | Replacements | Type |
310
+
| wp_posts | post_content | 1 | PHP |
311
+
312
+
When I run `wp post get {POST_ID} --field=post_content`
313
+
Then STDOUT should contain:
314
+
"""
315
+
http:\/\/example.com
316
+
"""
317
+
241
318
@require-mysql
242
319
Scenario: Search and replace with quoted strings
243
320
Given a WP install
@@ -884,6 +961,8 @@ Feature: Do global search/replace
884
961
"""
885
962
And STDERR should be empty
886
963
964
+
# See https://github.com/wp-cli/search-replace-command/issues/190
965
+
@skip-sqlite
887
966
Scenario: Logging with regex replace
888
967
Given a WP install
889
968
@@ -1246,6 +1325,8 @@ Feature: Do global search/replace
1246
1325
[field_count] => 2
1247
1326
"""
1248
1327
1328
+
# See https://github.com/wp-cli/search-replace-command/issues/190
1329
+
@skip-sqlite
1249
1330
Scenario: Regex search/replace with `--regex-limit=1` option
1250
1331
Given a WP install
1251
1332
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
@@ -1256,6 +1337,8 @@ Feature: Do global search/replace
1256
1337
I have a pen, I have an orange. Pen, pine-apple, apple-pen.
1257
1338
"""
1258
1339
1340
+
# See https://github.com/wp-cli/search-replace-command/issues/190
1341
+
@skip-sqlite
1259
1342
Scenario: Regex search/replace with `--regex-limit=2` option
1260
1343
Given a WP install
1261
1344
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
@@ -1266,6 +1349,8 @@ Feature: Do global search/replace
1266
1349
I have a pen, I have an orange. Pen, pine-orange, apple-pen.
1267
1350
"""
1268
1351
1352
+
# See https://github.com/wp-cli/search-replace-command/issues/190
1353
+
@skip-sqlite
1269
1354
Scenario: Regex search/replace with incorrect or default `--regex-limit`
1270
1355
Given a WP install
1271
1356
When I try `wp search-replace '(Hello)\s(world)''$2, $1' --regex --regex-limit=asdf`
@@ -1560,3 +1645,21 @@ Feature: Do global search/replace
1560
1645
"""
1561
1646
--old-content
1562
1647
"""
1648
+
1649
+
1650
+
@require-mysql
1651
+
Scenario: Warn when updating a table fails due to a database error
1652
+
Given a WP install
1653
+
And I run `wp db query "CREATE TABLE wp_readonly_test ( id int(11) unsigned NOT NULL AUTO_INCREMENT, data TEXT, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"`
1654
+
And I run `wp db query "INSERT INTO wp_readonly_test (data) VALUES ('old-value');"`
1655
+
And I run `wp db query "CREATE TRIGGER prevent_update BEFORE UPDATE ON wp_readonly_test FOR EACH ROW SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Table is read-only';"`
1656
+
1657
+
When I try `wp search-replace old-value new-value --all-tables-with-prefix`
1658
+
Then STDERR should contain:
1659
+
"""
1660
+
Error updating column 'data' in table 'wp_readonly_test'
0 commit comments