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
{{ message }}
Repository navigation
Commit b7d9e53
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This package is part of WP-CLI, the official command line interface for WordPress. For a detailed explanation of the project structure and development workflow, please refer to the main @README.md file.
4
4
5
+
If the repository contains an @AGENTS.local.md file, read it as well. It holds instructions specific to this repository and takes precedence over this file where the two disagree.
6
+
5
7
## Best Practices for Code Contributions
6
8
7
9
When contributing to this package, please adhere to the following guidelines:
Copy file name to clipboardExpand all lines: features/search-replace.feature
+50-4Lines changed: 50 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1579,9 +1579,8 @@ Feature: Do global search/replace
1579
1579
@require-mysql
1580
1580
Scenario: Warn when updating a table fails due to a database error
1581
1581
Given a WP install
1582
-
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;"`
1583
-
And I run `wp db query "INSERT INTO wp_readonly_test (data) VALUES ('old-value');"`
1584
-
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';"`
1582
+
And I run `wp db query "CREATE TABLE wp_readonly_test ( id int(11) unsigned NOT NULL AUTO_INCREMENT, data VARCHAR(191), PRIMARY KEY (id), UNIQUE KEY data (data) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"`
1583
+
And I run `wp db query "INSERT INTO wp_readonly_test (data) VALUES ('old-value'), ('new-value');"`
1585
1584
1586
1585
When I try `wp search-replace old-value new-value --all-tables-with-prefix`
1587
1586
Then STDERR should contain:
@@ -1590,7 +1589,54 @@ Feature: Do global search/replace
1590
1589
"""
1591
1590
And STDERR should contain:
1592
1591
"""
1593
-
Table is read-only
1592
+
Duplicate entry
1593
+
"""
1594
+
1595
+
@require-mysql
1596
+
Scenario: Report types and counts are based on serialized data in the column
1597
+
Given a WP install
1598
+
And I run `wp option add sr_serialized_match '{"url":"https://match.example/x"}' --format=json`
1599
+
And I run `wp option add sr_plain_match 'see https://match.example/y'`
1600
+
And I run `wp post create --post_title='Has match.example in it' --post_content='Plain match.example content' --porcelain`
1601
+
And save STDOUT as {POST_ID}
1602
+
1603
+
# option_value holds serialized data (the option above), so it is handled in PHP.
1604
+
# post_title has no serialized data, so it is handled in SQL. post_excerpt has no matches.
1605
+
When I run `wp search-replace match.example other.example --dry-run --include-columns=option_value,post_title,post_excerpt`
1606
+
Then STDOUT should be a table containing rows:
1607
+
| Table | Column | Replacements | Type |
1608
+
| wp_options | option_value | 2 | PHP |
1609
+
| wp_posts | post_title | 1 | SQL |
1610
+
| wp_posts | post_excerpt | 0 | SQL |
1611
+
1612
+
# A column with serialized data is reported as PHP even when none of it matches.
1613
+
When I run `wp search-replace no-such-string other.example --dry-run --include-columns=option_value`
1614
+
Then STDOUT should be a table containing rows:
1615
+
| Table | Column | Replacements | Type |
1616
+
| wp_options | option_value | 0 | PHP |
1617
+
1618
+
When I run `wp search-replace match.example other.example`
1619
+
Then STDOUT should contain:
1620
+
"""
1621
+
Success: Made 4 replacements.
1622
+
"""
1623
+
1624
+
When I run `wp option get sr_serialized_match --format=json`
1625
+
Then STDOUT should be:
1626
+
"""
1627
+
{"url":"https:\/\/other.example\/x"}
1628
+
"""
1629
+
1630
+
When I run `wp option get sr_plain_match`
1631
+
Then STDOUT should be:
1632
+
"""
1633
+
see https://other.example/y
1634
+
"""
1635
+
1636
+
When I run `wp post get {POST_ID} --field=post_content`
0 commit comments