Skip to content

Commit c1a4c7b

Browse files
authored
Merge branch 'main' into copilot/add-sqlite-compatibility
2 parents 769a79e + c397ba4 commit c1a4c7b

File tree

9 files changed

+91
-7
lines changed

9 files changed

+91
-7
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
24+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
2525
with:
2626
files: "composer.json"
2727

2828
- name: Set up PHP environment
2929
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
30+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
3131
with:
3232
php-version: 'latest'
3333
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
41+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

.github/workflows/issue-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ name: Issue and PR Triage
1313
required: false
1414
type: string
1515

16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
1623
jobs:
1724
issue-triage:
1825
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main

.github/workflows/welcome-new-contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- master
99

10+
permissions:
11+
pull-requests: write
12+
1013
jobs:
1114
welcome:
1215
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

.typos.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
"(#|//)\\s*spellchecker:ignore-next-line\\n.*"
6+
]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ Opens a MySQL console using credentials from wp-config.php
303303
wp db cli [--database=<database>] [--default-character-set=<character-set>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
304304
~~~
305305

306+
**Alias:** `connect`
307+
306308
**OPTIONS**
307309

308310
[--database=<database>]
@@ -432,6 +434,8 @@ Exports the database to a file or to STDOUT.
432434
wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--tables=<tables>] [--exclude_tables=<tables>] [--include-tablespaces] [--porcelain] [--add-drop-table] [--defaults]
433435
~~~
434436

437+
**Alias:** `dump`
438+
435439
Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
436440
`DB_PASSWORD` database credentials specified in wp-config.php. Accepts any valid `mysqldump` flags.
437441

features/db-check.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ Feature: Check the database
1515
"""
1616

1717
@require-mysql-or-mariadb
18+
Scenario: db check with --quiet flag should only show errors
19+
Given a WP install
20+
21+
When I run `wp db check --quiet`
22+
Then STDOUT should be empty
23+
24+
Scenario: db check can explicitly pass --silent to mysqlcheck
25+
Given a WP install
26+
27+
When I run `wp db check --silent`
28+
Then STDOUT should not contain:
29+
"""
30+
wp_cli_test.wp_users
31+
"""
32+
And STDOUT should contain:
33+
"""
34+
Success: Database checked.
35+
"""
36+
1837
Scenario: Run db check with MySQL defaults to check the database
1938
Given a WP install
2039

features/db.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,28 @@ Feature: Perform database operations
191191
And STDOUT should not be empty
192192
193193
@require-mysql-or-mariadb
194+
Scenario: db repair with --quiet flag should only show errors
195+
Given a WP install
196+
197+
When I run `wp db repair --quiet`
198+
Then STDOUT should not contain:
199+
"""
200+
error
201+
"""
202+
203+
Scenario: db repair can explicitly pass --silent to mysqlcheck
204+
Given a WP install
205+
206+
When I run `wp db repair --silent`
207+
Then STDOUT should not contain:
208+
"""
209+
error
210+
"""
211+
And STDOUT should contain:
212+
"""
213+
Success: Database repaired.
214+
"""
215+
194216
Scenario: DB Query
195217
Given a WP install
196218

src/DB_Command.php

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

33
use WP_CLI\Formatter;
44
use WP_CLI\Utils;
5+
use cli\table\Column;
56

67
require_once __DIR__ . '/DB_Command_SQLite.php';
78

@@ -293,6 +294,12 @@ public function check( $_, $assoc_args ) {
293294
WP_CLI::debug( "Running shell command: {$command}", 'db' );
294295

295296
$assoc_args['check'] = true;
297+
298+
// Pass --silent to mysqlcheck when in quiet mode.
299+
if ( WP_CLI::get_config( 'quiet' ) ) {
300+
$assoc_args['silent'] = true;
301+
}
302+
296303
self::run(
297304
Utils\esc_cmd( $command, DB_NAME ),
298305
$assoc_args
@@ -348,6 +355,12 @@ public function optimize( $_, $assoc_args ) {
348355
WP_CLI::debug( "Running shell command: {$command}", 'db' );
349356

350357
$assoc_args['optimize'] = true;
358+
359+
// Pass --silent to mysqlcheck when in quiet mode.
360+
if ( WP_CLI::get_config( 'quiet' ) ) {
361+
$assoc_args['silent'] = true;
362+
}
363+
351364
self::run(
352365
Utils\esc_cmd( $command, DB_NAME ),
353366
$assoc_args
@@ -403,6 +416,12 @@ public function repair( $_, $assoc_args ) {
403416
WP_CLI::debug( "Running shell command: {$command}", 'db' );
404417

405418
$assoc_args['repair'] = true;
419+
420+
// Pass --silent to mysqlcheck when in quiet mode.
421+
if ( WP_CLI::get_config( 'quiet' ) ) {
422+
$assoc_args['silent'] = true;
423+
}
424+
406425
self::run(
407426
Utils\esc_cmd( $command, DB_NAME ),
408427
$assoc_args
@@ -1308,7 +1327,6 @@ public function size( $args, $assoc_args ) {
13081327
if ( ! empty( $size_format ) && ! $tables && ! $format && ! $human_readable && true !== $all_tables && true !== $all_tables_with_prefix ) {
13091328
WP_CLI::line( str_replace( " {$size_format_display}", '', $rows[0]['Size'] ) );
13101329
} else {
1311-
13121330
// Sort the rows by user input
13131331
if ( $orderby ) {
13141332
usort(
@@ -1329,7 +1347,8 @@ function ( $a, $b ) use ( $order, $orderby ) {
13291347

13301348
// Display the rows.
13311349
$args = [
1332-
'format' => $format,
1350+
'format' => $format,
1351+
'alignments' => [ 'Size' => Column::ALIGN_RIGHT ],
13331352
];
13341353

13351354
$formatter = new Formatter( $args, $fields );
@@ -1930,7 +1949,7 @@ private static function run( $cmd, $assoc_args = [], $send_to_shell = true, $int
19301949
$required['default-character-set'] = constant( 'DB_CHARSET' );
19311950
}
19321951

1933-
// Using 'dbuser' as option name to workaround clash with WP-CLI's global WP 'user' parameter, with 'dbpass' also available for tidyness.
1952+
// Using 'dbuser' as option name to workaround clash with WP-CLI's global WP 'user' parameter, with 'dbpass' also available for tidiness.
19341953
if ( isset( $assoc_args['dbuser'] ) ) {
19351954
$required['user'] = $assoc_args['dbuser'];
19361955
unset( $assoc_args['dbuser'] );

0 commit comments

Comments
 (0)