Skip to content

Commit 7e2ba87

Browse files
authored
Merge branch 'main' into claude/search-replace-single-scan
2 parents 24d205f + 5181346 commit 7e2ba87

5 files changed

Lines changed: 43 additions & 21 deletions

File tree

‎.github/actionlint.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ paths:
1111
# catching genuine typos in permission names.
1212
# See https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli-in-actions
1313
- 'unknown permission scope "copilot-requests"'
14+
# Steps can run in parallel through the `background`, `wait`, `wait-all`,
15+
# `cancel` and `parallel` keywords, but actionlint does not know them yet:
16+
# it rejects `background` as an unexpected key, and a `wait-all` or
17+
# `parallel` step as one that has neither `run` nor `uses`. Drop these
18+
# entries once actionlint supports the keywords. Until then, a step that is
19+
# genuinely missing both `run` and `uses` is no longer reported.
20+
# See https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsparallel
21+
- 'unexpected key "background" for step'
22+
- 'step must run script with "run" section or run action with "uses" section'

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,30 @@ jobs:
3939
id: check_composer_file
4040
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
4141

42+
# Without a database the Behat runner silently falls back to SQLite, so the
43+
# agent's test runs are not the ones CI will do. Mirrors the setup in
44+
# reusable-functional.yml.
45+
- name: Check existence of behat.yml file
46+
id: check_behat_file
47+
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
48+
49+
# Downloading and starting the database server is the slowest part of the
50+
# setup and it is independent of PHP and Composer, so it runs in the
51+
# background and is waited for right before the test database is prepared.
52+
- name: Setup MySQL Server
53+
if: steps.check_behat_file.outputs.files_exists == 'true'
54+
background: true
55+
uses: shogo82148/actions-setup-mysql@13a38f2af408e58a0c80168fc620a63a15357339 # v1
56+
with:
57+
mysql-version: '8.0' # Standard MySQL version for these tests
58+
auto-start: true
59+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
60+
user: ${{ env.WP_CLI_TEST_DBUSER }}
61+
password: ${{ env.WP_CLI_TEST_DBPASS }}
62+
4263
- name: Set up PHP environment
4364
if: steps.check_composer_file.outputs.files_exists == 'true'
44-
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
65+
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
4566
with:
4667
php-version: 'latest'
4768
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -56,22 +77,8 @@ jobs:
5677
env:
5778
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
5879

59-
# Without a database the Behat runner silently falls back to SQLite, so the
60-
# agent's test runs are not the ones CI will do. Mirrors the setup in
61-
# reusable-functional.yml.
62-
- name: Check existence of behat.yml file
63-
id: check_behat_file
64-
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
65-
66-
- name: Setup MySQL Server
67-
if: steps.check_behat_file.outputs.files_exists == 'true'
68-
uses: shogo82148/actions-setup-mysql@083ec148d28e62f2b24b8f4541693dfe1d50488d # v1
69-
with:
70-
mysql-version: '8.0' # Standard MySQL version for these tests
71-
auto-start: true
72-
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
73-
user: ${{ env.WP_CLI_TEST_DBUSER }}
74-
password: ${{ env.WP_CLI_TEST_DBPASS }}
80+
- name: Wait for the MySQL server
81+
wait-all:
7582

7683
- name: Remove system MySQL binary
7784
if: steps.check_behat_file.outputs.files_exists == 'true'

‎AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
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.
44

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+
57
## Best Practices for Code Contributions
68

79
When contributing to this package, please adhere to the following guidelines:

‎features/search-replace.feature‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,9 +1579,8 @@ Feature: Do global search/replace
15791579
@require-mysql
15801580
Scenario: Warn when updating a table fails due to a database error
15811581
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');"`
15851584

15861585
When I try `wp search-replace old-value new-value --all-tables-with-prefix`
15871586
Then STDERR should contain:
@@ -1590,7 +1589,7 @@ Feature: Do global search/replace
15901589
"""
15911590
And STDERR should contain:
15921591
"""
1593-
Table is read-only
1592+
Duplicate entry
15941593
"""
15951594

15961595
@require-mysql

‎src/Search_Replace_Command.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ class Search_Replace_Command extends WP_CLI_Command {
140140
* Search/replace intelligently handles PHP serialized data, and does not
141141
* change primary key values.
142142
*
143+
* The JSON-encoded form of the search string is replaced as well, so a
144+
* search for `https://example.com` also matches `https:\/\/example.com`
145+
* in JSON stored in the database. This does not apply with `--regex`,
146+
* where the pattern itself has to account for escaped slashes.
147+
*
143148
* Tables without a primary key are skipped. To check whether a table has a
144149
* primary key, run `wp db query 'DESCRIBE <table>'` and look for 'PRI' in
145150
* the Key column.

0 commit comments

Comments
 (0)