Skip to content

Commit 7eb293c

Browse files
committed
Merge remote-tracking branch 'origin/main' into copilot/add-wp-db-users-command
2 parents f23449f + 9423837 commit 7eb293c

19 files changed

Lines changed: 1282 additions & 507 deletions

‎.github/actionlint.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Configuration for actionlint, run by the `actionlint` job in
2+
# `.github/workflows/reusable-code-quality.yml`.
3+
paths:
4+
.github/workflows/**/*.{yml,yaml}:
5+
ignore:
6+
# `copilot-requests` is a real permission scope - it is what lets a
7+
# workflow authenticate the Copilot CLI with the built-in `GITHUB_TOKEN`
8+
# instead of a personal access token - but actionlint's hard-coded scope
9+
# list has not caught up with it yet, so it reports every use as unknown.
10+
# Drop this entry once actionlint ships the scope, and it will go back to
11+
# catching genuine typos in permission names.
12+
# See https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli-in-actions
13+
- '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/dependabot.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,29 @@ updates:
77
open-pull-requests-limit: 10
88
labels:
99
- scope:distribution
10+
cooldown:
11+
default-days: 7
12+
# Packages from our own org are trusted, so they are updated immediately.
13+
exclude:
14+
- "wp-cli/*"
15+
# Only wp-cli-tests carries a package.json, holding the pinned version of the
16+
# Gherkin linter. This is a no-op in every other repository.
17+
- package-ecosystem: npm
18+
directory: "/"
19+
schedule:
20+
interval: daily
21+
open-pull-requests-limit: 10
22+
labels:
23+
- scope:distribution
24+
cooldown:
25+
default-days: 7
1026
- package-ecosystem: github-actions
1127
directory: "/"
1228
schedule:
1329
interval: daily
1430
open-pull-requests-limit: 10
1531
labels:
1632
- scope:distribution
33+
cooldown:
34+
default-days: 7
1735

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,50 @@ jobs:
1919
permissions:
2020
contents: read
2121

22+
env:
23+
MYSQL_HOST: 127.0.0.1
24+
MYSQL_TCP_PORT: 3306
25+
WP_CLI_TEST_DBROOTUSER: root
26+
WP_CLI_TEST_DBROOTPASS: root
27+
WP_CLI_TEST_DBNAME: wp_cli_test
28+
WP_CLI_TEST_DBUSER: wp_cli_test
29+
WP_CLI_TEST_DBPASS: password1
30+
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
31+
2232
steps:
2333
- name: Checkout code
24-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
34+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2535
with:
2636
persist-credentials: false
2737

2838
- name: Check existence of composer.json file
2939
id: check_composer_file
3040
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
3141

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+
# Not run in the background: Copilot code review builds its workflow from
50+
# these steps and failed validation while they used `background` and
51+
# `wait-all`. Also, the action unpacks its binaries with the system `tar`,
52+
# which fails to load libpcre2 while setup-php upgrades it with apt.
53+
- name: Setup MySQL Server
54+
if: steps.check_behat_file.outputs.files_exists == '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+
3263
- name: Set up PHP environment
3364
if: steps.check_composer_file.outputs.files_exists == 'true'
34-
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
65+
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
3566
with:
3667
php-version: 'latest'
3768
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -45,3 +76,11 @@ jobs:
4576
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4677
env:
4778
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
79+
80+
- name: Remove system MySQL binary
81+
if: steps.check_behat_file.outputs.files_exists == 'true'
82+
run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump
83+
84+
- name: Prepare test database
85+
if: steps.check_behat_file.outputs.files_exists == 'true'
86+
run: composer prepare-tests

‎.github/workflows/issue-triage.yml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ name: Issue and PR Triage
1616
permissions:
1717
issues: write
1818
pull-requests: write
19-
actions: write
2019
contents: read
21-
models: read
20+
# A caller can only cap a reusable workflow's permissions, so the scope the
21+
# Copilot CLI needs has to be granted here too. `models: read` was for the
22+
# GitHub Models provider, which `actions/ai-inference` v3 removed.
23+
copilot-requests: write
24+
# A caller can only cap a reusable workflow's permissions, never raise them,
25+
# so `actions: write` has to be granted here for the dispatch job downstream
26+
# to work at all. The reusable workflow narrows it to that single job, so the
27+
# `pull_request_target` job does not receive it. Removing it here breaks
28+
# dispatching (see #271/#272); narrow it there instead.
29+
actions: write
2230

2331
jobs:
2432
issue-triage:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Milestone Merged Pull Requests
3+
4+
'on':
5+
pull_request_target:
6+
types: [closed]
7+
branches:
8+
- main
9+
- master
10+
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
milestone:
17+
uses: wp-cli/.github/.github/workflows/reusable-milestone-merged-prs.yml@main

‎AGENTS.md‎

Lines changed: 23 additions & 2 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:
@@ -13,9 +15,27 @@ When contributing to this package, please adhere to the following guidelines:
1315

1416
### Building and running
1517

16-
Before submitting any changes, it is crucial to validate them by running the full suite of static code analysis and tests. To run the full suite of checks, execute the following command: `composer test`.
18+
Run the narrowest check that covers your change:
19+
20+
| You changed | Run |
21+
| --- | --- |
22+
| Any PHP file | `composer phpcs -- <file>` and `composer phpstan` |
23+
| Logic with unit test coverage | `composer phpunit -- --filter <TestName>` |
24+
| One feature file | `composer behat -- features/<name>.feature` |
25+
| One scenario | `composer behat -- features/<name>.feature:<line>` |
26+
27+
After a failure, `composer behat-rerun` re-runs only the scenarios that failed, and `composer behat -- --stop-on-failure` bails out at the first one instead of working through the rest.
28+
29+
`composer test` runs every suite, the whole Behat suite included. In most packages that means installing WordPress from scratch once per scenario, which takes tens of minutes and needs `jq`, a MySQL or MariaDB client with a prepared test database, and network access to WordPress.org. Run it before opening a pull request when you have touched something cross-cutting. Do not run it to check a two-line change.
30+
31+
Set these first, so the tools report problems compactly instead of drawing progress bars and ANSI color into output you are going to read back:
32+
33+
```bash
34+
export NO_COLOR=1
35+
export WP_CLI_TEST_QUIET=1
36+
```
1737

18-
This single command ensures that your changes meet all the quality gates of the project. While you can run the individual steps separately, it is highly recommended to use this single command to ensure a comprehensive validation.
38+
Note that a green `composer test` is not the same as a green CI. `actionlint` and `typos` also run on every pull request and are not part of it.
1939

2040
### Useful Composer Commands
2141

@@ -24,6 +44,7 @@ The project uses Composer to manage dependencies and run scripts. The following
2444
* `composer install`: Install dependencies.
2545
* `composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
2646
* `composer lint`: Check for syntax errors.
47+
* `composer lint-gherkin`: Check the Behat feature files for style violations.
2748
* `composer phpcs`: Check for code style violations.
2849
* `composer phpcbf`: Automatically fix code style violations.
2950
* `composer phpstan`: Run static analysis.

‎README.md‎

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ wp db cli [--database=<database>] [--default-character-set=<character-set>] [--d
338338
Executes a SQL query against the database.
339339

340340
~~~
341-
wp db query [<sql>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
341+
wp db query [<sql>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults] [--skip-sql-mode-compat]
342342
~~~
343343

344344
Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER`
@@ -365,6 +365,13 @@ entirely.
365365
[--defaults]
366366
Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration.
367367

368+
[--skip-sql-mode-compat]
369+
Run the query under the server's own SQL modes instead of adapting them to
370+
be WordPress-compatible. By default, the incompatible modes that WordPress
371+
disables in `wpdb` (such as `NO_ZERO_DATE` and `STRICT_TRANS_TABLES`) are
372+
stripped for the session, so statements against WordPress's zero-date schema
373+
behave the same as they do in WordPress itself.
374+
368375
**EXAMPLES**
369376

370377
# Execute a query stored in a file
@@ -437,7 +444,7 @@ wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
437444
**Alias:** `dump`
438445

439446
Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
440-
`DB_PASSWORD` database credentials specified in wp-config.php. Accepts any valid `mysqldump` flags.
447+
`DB_PASSWORD` database credentials specified in wp-config.php. Accepts any valid [`mysqldump` flags](https://dev.mysql.com/doc/en/mysqldump.html#mysqldump-option-summary).
441448

442449
**OPTIONS**
443450

@@ -523,7 +530,7 @@ Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
523530
Imports a database from a file or from STDIN.
524531

525532
~~~
526-
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization] [--defaults]
533+
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization] [--skip-sql-mode-compat] [--defaults]
527534
~~~
528535

529536
Runs SQL queries using `DB_HOST`, `DB_NAME`, `DB_USER` and
@@ -546,7 +553,10 @@ defined in the SQL.
546553
Extra arguments to pass to mysql. [Refer to mysql binary docs](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html).
547554

548555
[--skip-optimization]
549-
When using an SQL file, do not include speed optimization such as disabling auto-commit and key checks.
556+
Do not disable unique checks and foreign key checks during import.
557+
558+
[--skip-sql-mode-compat]
559+
Do not adapt the session SQL mode for WordPress compatibility. By default, `wp db import` strips the SQL modes that WordPress Core disables (such as `STRICT_TRANS_TABLES` and `NO_ZERO_DATE`) so that dumps containing legacy values like `0000-00-00` import cleanly. Pass this flag to import under the server's own SQL modes instead.
550560

551561
[--defaults]
552562
Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration.
@@ -816,12 +826,17 @@ Defaults to all tables registered to the $wpdb database handler.
816826
Displays the database name and size.
817827

818828
~~~
819-
wp db size [--size_format=<format>] [--tables] [--human-readable] [--format=<format>] [--scope=<scope>] [--network] [--decimals=<decimals>] [--all-tables-with-prefix] [--all-tables] [--order=<order>] [--orderby=<orderby>]
829+
wp db size [--size_format=<format>] [--tables] [--human-readable] [--fields=<fields>] [--format=<format>] [--scope=<scope>] [--network] [--decimals=<decimals>] [--all-tables-with-prefix] [--all-tables] [--order=<order>] [--orderby=<orderby>]
820830
~~~
821831

822832
Display the database name and size for `DB_NAME` specified in wp-config.php.
823833
The size defaults to a human-readable number.
824834

835+
The reported size is the sum of the data and the index size. Both can be
836+
displayed separately by adding them to `--fields`. For SQLite, the database
837+
size is the size of the database file, which also includes overhead such as
838+
free pages.
839+
825840
Available size formats include:
826841
* b (bytes)
827842
* kb (kilobytes)
@@ -866,6 +881,9 @@ Available size formats include:
866881
[--human-readable]
867882
Display database sizes in human readable formats.
868883

884+
[--fields=<fields>]
885+
Get a specific subset of the fields.
886+
869887
[--format=<format>]
870888
Render output in a particular format.
871889
---
@@ -883,7 +901,7 @@ Available size formats include:
883901
List all the tables in a multisite install.
884902

885903
[--decimals=<decimals>]
886-
Number of digits after decimal point. Defaults to 0.
904+
Number of digits after decimal point. Defaults to 0, or 2 when using --human-readable.
887905

888906
[--all-tables-with-prefix]
889907
List all tables that match the table prefix even if not registered on $wpdb. Overrides --network.
@@ -909,6 +927,18 @@ Available size formats include:
909927
- size
910928
---
911929

930+
**AVAILABLE FIELDS**
931+
932+
These fields will be displayed by default:
933+
934+
* Name
935+
* Size
936+
937+
These fields are optionally available:
938+
939+
* Data
940+
* Index
941+
912942
**EXAMPLES**
913943

914944
$ wp db size
@@ -936,6 +966,13 @@ Available size formats include:
936966
| wp_commentmeta | 48 KB |
937967
+-----------------------+-------+
938968

969+
$ wp db size --fields=Name,Data,Index,Size --human-readable
970+
+-------------------+---------+--------+---------+
971+
| Name | Data | Index | Size |
972+
+-------------------+---------+--------+---------+
973+
| wordpress_default | 3.43 GB | 2.8 GB | 6.23 GB |
974+
+-------------------+---------+--------+---------+
975+
939976
$ wp db size --size_format=b
940977
5865472
941978

@@ -1038,7 +1075,7 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
10381075

10391076
## Support
10401077

1041-
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
1078+
GitHub issues aren't for general support questions. For support resources and next steps, see the WP-CLI Support page: https://make.wordpress.org/cli/handbook/support/
10421079

10431080

10441081
*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*

‎composer.json‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.13"
15+
"wp-cli/wp-cli": "^3.0"
1616
},
1717
"require-dev": {
18-
"wp-cli/entity-command": "^1.3 || ^2",
18+
"wp-cli/entity-command": "^1.3 || ^2 || ^3",
1919
"wp-cli/wp-cli-tests": "^5"
2020
},
2121
"config": {
@@ -30,7 +30,7 @@
3030
},
3131
"extra": {
3232
"branch-alias": {
33-
"dev-main": "2.x-dev"
33+
"dev-main": "3.x-dev"
3434
},
3535
"bundled": true,
3636
"commands": [
@@ -69,13 +69,15 @@
6969
"behat": "run-behat-tests",
7070
"behat-rerun": "rerun-behat-tests",
7171
"lint": "run-linter-tests",
72+
"lint-gherkin": "run-gherkin-lint-tests",
7273
"phpcs": "run-phpcs-tests",
7374
"phpstan": "run-phpstan-tests",
7475
"phpcbf": "run-phpcbf-cleanup",
7576
"phpunit": "run-php-unit-tests",
7677
"prepare-tests": "install-package-tests",
7778
"test": [
7879
"@lint",
80+
"@lint-gherkin",
7981
"@phpcs",
8082
"@phpunit",
8183
"@behat"

0 commit comments

Comments
 (0)