Skip to content

Commit 83853da

Browse files
authored
Merge branch 'main' into patch-1
2 parents c79679e + 2556346 commit 83853da

21 files changed

Lines changed: 1323 additions & 85 deletions

‎.gitattributes‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/.actrc export-ignore
2+
/.distignore export-ignore
3+
/.editorconfig export-ignore
4+
/.github export-ignore
5+
/.gitignore export-ignore
6+
/.typos.toml export-ignore
7+
/AGENTS.md export-ignore
8+
/behat.yml export-ignore
9+
/features export-ignore
10+
/phpcs.xml.dist export-ignore
11+
/phpstan.neon.dist export-ignore
12+
/phpunit.xml.dist export-ignore
13+
/tests export-ignore
14+
/wp-cli.yml export-ignore

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ jobs:
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
25-
with:
26-
files: "composer.json"
24+
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2725

2826
- name: Set up PHP environment
2927
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
28+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
3129
with:
3230
php-version: 'latest'
3331
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,9 +36,6 @@ jobs:
3836

3937
- name: Install Composer dependencies & cache dependencies
4038
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
39+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
4240
env:
4341
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
44-
with:
45-
# Bust the cache at least once a month - output format: YYYY-MM.
46-
custom-cache-suffix: $(date -u "+%Y-%m")

‎README.md‎

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ wp-cli/db-command
33

44
Performs basic database operations using credentials stored in wp-config.php.
55

6-
[![Testing](https://github.com/wp-cli/db-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/db-command/actions/workflows/testing.yml)
6+
[![Testing](https://github.com/wp-cli/db-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/db-command/actions/workflows/testing.yml) [![Code Coverage](https://codecov.io/gh/wp-cli/db-command/branch/main/graph/badge.svg)](https://codecov.io/gh/wp-cli/db-command/tree/main)
77

88
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)
99

@@ -655,39 +655,39 @@ Defaults to searching through all tables registered to $wpdb. On multisite, this
655655
- count
656656
---
657657

658-
The percent color codes available are:
659-
660-
| Code | Color
661-
| ---- | -----
662-
| %y | Yellow (dark) (mustard)
663-
| %g | Green (dark)
664-
| %b | Blue (dark)
665-
| %r | Red (dark)
666-
| %m | Magenta (dark)
667-
| %c | Cyan (dark)
668-
| %w | White (dark) (light gray)
669-
| %k | Black
670-
| %Y | Yellow (bright)
671-
| %G | Green (bright)
672-
| %B | Blue (bright)
673-
| %R | Red (bright)
674-
| %M | Magenta (bright)
675-
| %C | Cyan (bright)
676-
| %W | White
677-
| %K | Black (bright) (dark gray)
678-
| %3 | Yellow background (dark) (mustard)
679-
| %2 | Green background (dark)
680-
| %4 | Blue background (dark)
681-
| %1 | Red background (dark)
682-
| %5 | Magenta background (dark)
683-
| %6 | Cyan background (dark)
684-
| %7 | White background (dark) (light gray)
685-
| %0 | Black background
686-
| %8 | Reverse
687-
| %U | Underline
688-
| %F | Blink (unlikely to work)
689-
690-
They can be concatenated. For instance, the default match color of black on a mustard (dark yellow) background `%3%k` can be made black on a bright yellow background with `%Y%0%8`.
658+
The percent color codes available are:
659+
660+
| Code | Color
661+
| ---- | -----
662+
| %y | Yellow (dark) (mustard)
663+
| %g | Green (dark)
664+
| %b | Blue (dark)
665+
| %r | Red (dark)
666+
| %m | Magenta (dark)
667+
| %c | Cyan (dark)
668+
| %w | White (dark) (light gray)
669+
| %k | Black
670+
| %Y | Yellow (bright)
671+
| %G | Green (bright)
672+
| %B | Blue (bright)
673+
| %R | Red (bright)
674+
| %M | Magenta (bright)
675+
| %C | Cyan (bright)
676+
| %W | White
677+
| %K | Black (bright) (dark gray)
678+
| %3 | Yellow background (dark) (mustard)
679+
| %2 | Green background (dark)
680+
| %4 | Blue background (dark)
681+
| %1 | Red background (dark)
682+
| %5 | Magenta background (dark)
683+
| %6 | Cyan background (dark)
684+
| %7 | White background (dark) (light gray)
685+
| %0 | Black background
686+
| %8 | Reverse
687+
| %U | Underline
688+
| %F | Blink (unlikely to work)
689+
690+
They can be concatenated. For instance, the default match color of black on a mustard (dark yellow) background `%3%k` can be made black on a bright yellow background with `%Y%0%8`.
691691

692692
**AVAILABLE FIELDS**
693693

@@ -766,7 +766,22 @@ Defaults to all tables registered to the $wpdb database handler.
766766
List tables based on wildcard search, e.g. 'wp_*_options' or 'wp_post?'.
767767

768768
[--scope=<scope>]
769-
Can be all, global, ms_global, blog, or old tables. Defaults to all.
769+
List tables based on the scope.
770+
771+
- all: returns 'all' and 'global' tables. No old tables are returned.
772+
- blog: returns the blog-level tables for the queried blog.
773+
- global: returns the global tables for the installation, returning multisite tables only on multisite.
774+
- ms_global: returns the multisite global tables, regardless if current installation is multisite.
775+
- old: returns tables which are deprecated.
776+
---
777+
default: all
778+
options:
779+
- all
780+
- blog
781+
- global
782+
- ms_global
783+
- old
784+
---
770785

771786
[--network]
772787
List all the tables in a multisite install.
@@ -1027,6 +1042,10 @@ Want to contribute a new feature? Please first [open a new issue](https://github
10271042

10281043
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.
10291044

1045+
### License
1046+
1047+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
1048+
10301049
## Support
10311050

10321051
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support

‎codecov.yml‎

Whitespace-only changes.

‎features/db-check.feature‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Feature: Check the database
22

3+
@require-mysql-or-mariadb
34
Scenario: Run db check to check the database
45
Given a WP install
56

@@ -13,12 +14,14 @@ Feature: Check the database
1314
Success: Database checked.
1415
"""
1516

17+
@require-mysql-or-mariadb
1618
Scenario: db check with --quiet flag should only show errors
1719
Given a WP install
1820

1921
When I run `wp db check --quiet`
2022
Then STDOUT should be empty
2123

24+
@require-mysql-or-mariadb
2225
Scenario: db check can explicitly pass --silent to mysqlcheck
2326
Given a WP install
2427

@@ -32,6 +35,7 @@ Feature: Check the database
3235
Success: Database checked.
3336
"""
3437

38+
@require-mysql-or-mariadb
3539
Scenario: Run db check with MySQL defaults to check the database
3640
Given a WP install
3741

@@ -45,6 +49,7 @@ Feature: Check the database
4549
Success: Database checked.
4650
"""
4751

52+
@require-mysql-or-mariadb
4853
Scenario: Run db check with --no-defaults to check the database
4954
Given a WP install
5055

@@ -58,6 +63,7 @@ Feature: Check the database
5863
Success: Database checked.
5964
"""
6065

66+
@require-mysql-or-mariadb
6167
Scenario: Run db check with passed-in options
6268
Given a WP install
6369

@@ -143,6 +149,7 @@ Feature: Check the database
143149
"""
144150
And STDOUT should be empty
145151

152+
@require-mysql-or-mariadb
146153
Scenario: MySQL defaults are available as appropriate with --defaults flag
147154
Given a WP install
148155

@@ -155,3 +162,12 @@ Feature: Check the database
155162
When I try `wp db check --no-defaults --debug`
156163
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s#
157164

165+
@require-sqlite
166+
Scenario: SQLite commands that show warnings
167+
Given a WP install
168+
169+
When I try `wp db check`
170+
Then STDERR should contain:
171+
"""
172+
Warning: Database check is not supported for SQLite databases
173+
"""

‎features/db-cli.feature‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Open a MySQL console
2+
3+
@require-sqlite
4+
Scenario: SQLite commands that show warnings for cli
5+
Given a WP install
6+
7+
When I try `wp db cli`
8+
Then STDERR should contain:
9+
"""
10+
Warning: Interactive console (cli) is not supported for SQLite databases
11+
"""

‎features/db-columns.feature‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: Display information about a given table.
22

33
# This requires conditional tags to target different DB versions, as bigint(20) is only bigint on MySQL 8.
4-
@require-wp-4.2 @broken
4+
@broken
55
Scenario: Display information about the wp_posts table
66
Given a WP install
77

@@ -41,6 +41,7 @@ Feature: Display information about a given table.
4141
Couldn't find any tables matching: wp_foobar
4242
"""
4343

44+
@require-mysql-or-mariadb
4445
Scenario: Display information about a non default WordPress table
4546
Given a WP install
4647
And I run `wp db query "CREATE TABLE not_wp ( date DATE NOT NULL, awesome_stuff TEXT, PRIMARY KEY (date) );;"`
@@ -50,3 +51,14 @@ Feature: Display information about a given table.
5051
| Field | Type | Null | Key | Default | Extra |
5152
| date | date | NO | PRI | | |
5253
| awesome_stuff | text | YES | | | |
54+
55+
@require-sqlite
56+
Scenario: Display information about a non default WordPress table
57+
Given a WP install
58+
And I run `wp db query "CREATE TABLE not_wp ( date DATE NOT NULL, awesome_stuff TEXT, PRIMARY KEY (date) );;"`
59+
60+
When I try `wp db columns not_wp`
61+
Then STDOUT should be a table containing rows:
62+
| Field | Type | Null | Key | Default |
63+
| date | TEXT | NO | PRI | '' |
64+
| awesome_stuff | TEXT | YES | | |

‎features/db-create.feature‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Feature: Create a new database
2+
3+
@require-mysql-or-mariadb
4+
Scenario: Create a new database
5+
Given an empty directory
6+
And WP files
7+
And wp-config.php
8+
9+
When I run `wp db create`
10+
Then STDOUT should contain:
11+
"""
12+
Success: Database created.
13+
"""
14+
15+
@require-sqlite
16+
Scenario: SQLite DB create operation should fail if already existing
17+
Given a WP install
18+
19+
When I try `wp db create`
20+
Then the return code should be 1
21+
And STDERR should contain:
22+
"""
23+
Database already exists
24+
"""

0 commit comments

Comments
 (0)