Skip to content

Commit 6231130

Browse files
authored
Merge branch 'main' into copilot/fix-sql-mode-checks
2 parents 3c1cff3 + 4de3dfa commit 6231130

8 files changed

Lines changed: 146 additions & 63 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ on:
99
paths:
1010
- .github/workflows/copilot-setup-steps.yml
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
copilot-setup-steps:
17+
name: Setup environment
1418
runs-on: ubuntu-latest
1519
permissions:
1620
contents: read
1721

1822
steps:
1923
- name: Checkout code
2024
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
25+
with:
26+
persist-credentials: false
2127

2228
- name: Check existence of composer.json file
2329
id: check_composer_file
2430
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2531

2632
- name: Set up PHP environment
2733
if: steps.check_composer_file.outputs.files_exists == 'true'
28-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
34+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
2935
with:
3036
php-version: 'latest'
3137
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -36,6 +42,6 @@ jobs:
3642

3743
- name: Install Composer dependencies & cache dependencies
3844
if: steps.check_composer_file.outputs.files_exists == 'true'
39-
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
45+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4046
env:
4147
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ To confirm the ID for the site you want to query, you can use the `wp site list`
431431
Exports the database to a file or to STDOUT.
432432

433433
~~~
434-
wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--tables=<tables>] [--exclude_tables=<tables>] [--include-tablespaces] [--porcelain] [--add-drop-table] [--defaults]
434+
wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--tables=<tables>] [--exclude_tables=<tables>] [--include-tablespaces] [--porcelain] [--defaults]
435435
~~~
436436

437437
**Alias:** `dump`
@@ -466,16 +466,13 @@ Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
466466
[--porcelain]
467467
Output filename for the exported database.
468468

469-
[--add-drop-table]
470-
Include a `DROP TABLE IF EXISTS` statement before each `CREATE TABLE` statement.
471-
472469
[--defaults]
473470
Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration.
474471

475472
**EXAMPLES**
476473

477-
# Export database with drop query included
478-
$ wp db export --add-drop-table
474+
# Export database with `--skip-opt` and `--add-drop-table` mysqldump flags
475+
$ wp db export --skip-opt --add-drop-table
479476
Success: Exported to 'wordpress_dbase-db72bb5.sql'.
480477

481478
# Export certain tables

features/db-export.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,16 @@ Feature: Export a WordPress database
147147

148148
When I try `wp db export --no-defaults --debug`
149149
Then STDERR should match #Debug \(db\): Running initial shell command: /usr/bin/env (mysqldump|mariadb-dump) --no-defaults#
150+
151+
@skip-sqlite
152+
@skip-windows
153+
Scenario: Export database when PHP exec() is disabled
154+
Given a WP install
155+
156+
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export wp_cli_test.sql --porcelain`
157+
Then the return code should be 0
158+
And STDOUT should contain:
159+
"""
160+
wp_cli_test.sql
161+
"""
162+
And the wp_cli_test.sql file should exist

features/db-search.feature

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -679,19 +679,19 @@ Feature: Search through the database
679679
:あいうえおかきくけこさしすせとたちつてと
680680
"""
681681

682-
When I run `wp db search 'ppppp' --before_context=3 --after_context=4`
682+
When I run `wp db search "ppppp" --before_context=3 --after_context=4`
683683
Then STDOUT should contain:
684684
"""
685685
:ムnöppppp
686686
"""
687687

688-
When I run `wp db search 'ppppp' --before_context=1 --after_context=1`
688+
When I run `wp db search "ppppp" --before_context=1 --after_context=1`
689689
Then STDOUT should contain:
690690
"""
691691
:öppppp
692692
"""
693693

694-
When I run `wp db search 'ムn' --before_context=2 --after_context=1`
694+
When I run `wp db search "ムn" --before_context=2 --after_context=1`
695695
Then STDOUT should contain:
696696
"""
697697
:llムnö
@@ -701,7 +701,7 @@ Feature: Search through the database
701701
:llムnöp
702702
"""
703703

704-
When I run `wp db search 'ムn' --before_context=2 --after_context=2`
704+
When I run `wp db search "ムn" --before_context=2 --after_context=2`
705705
Then STDOUT should contain:
706706
"""
707707
:llムnöp
@@ -720,7 +720,7 @@ Feature: Search through the database
720720
# Note ö is o with combining umlaut.
721721
And I run `wp option update regextst_combining 'lllllムnöppppp'`
722722

723-
When I run `wp db search 'https?:\/\/example.c.m' --regex`
723+
When I run `wp db search "https?:\/\/example.c.m" --regex`
724724
Then STDOUT should contain:
725725
"""
726726
wp_options:option_value
@@ -731,10 +731,10 @@ Feature: Search through the database
731731
[...]
732732
"""
733733

734-
When I run `wp db search 'unfindable' --regex`
734+
When I run `wp db search "unfindable" --regex`
735735
Then STDOUT should be empty
736736

737-
When I try `wp db search 'unfindable' --regex --regex-flags='abcd'`
737+
When I try `wp db search "unfindable" --regex --regex-flags="abcd"`
738738
Then STDERR should contain:
739739
"""
740740
unfindable
@@ -745,42 +745,42 @@ Feature: Search through the database
745745
"""
746746
And the return code should be 1
747747

748-
When I try `wp db search 'unfindable' --regex --regex-delimiter='1'`
748+
When I try `wp db search "unfindable" --regex --regex-delimiter="1"`
749749
Then STDERR should be:
750750
"""
751751
Error: The regex '1unfindable1' fails.
752752
"""
753753
And the return code should be 1
754754

755-
When I try `wp db search 'regex error)' --regex`
755+
When I try `wp db search "regex error)" --regex`
756756
Then STDERR should be:
757757
"""
758758
Error: The regex pattern 'regex error)' with default delimiter 'chr(1)' and no flags fails.
759759
"""
760760
And the return code should be 1
761761

762-
When I try `wp db search 'regex error)' --regex --regex-flags=u`
762+
When I try `wp db search "regex error)" --regex --regex-flags=u`
763763
Then STDERR should be:
764764
"""
765765
Error: The regex pattern 'regex error)' with default delimiter 'chr(1)' and flags 'u' fails.
766766
"""
767767
And the return code should be 1
768768

769-
When I try `wp db search 'regex error)' --regex --regex-delimiter=/`
769+
When I try `wp db search "regex error)" --regex --regex-delimiter=#`
770770
Then STDERR should be:
771771
"""
772-
Error: The regex '/regex error)/' fails.
772+
Error: The regex '#regex error)#' fails.
773773
"""
774774
And the return code should be 1
775775

776-
When I try `wp db search 'regex error)' --regex --regex-delimiter=/ --regex-flags=u`
776+
When I try `wp db search "regex error)" --regex --regex-delimiter=# --regex-flags=u`
777777
Then STDERR should be:
778778
"""
779-
Error: The regex '/regex error)/u' fails.
779+
Error: The regex '#regex error)#u' fails.
780780
"""
781781
And the return code should be 1
782782

783-
When I run `wp db search '[0-9é]+?https:' --regex --regex-flags=u --before_context=0 --after_context=0`
783+
When I run `wp db search "[0-9é]+?https:" --regex --regex-flags=u --before_context=0 --after_context=0`
784784
Then STDOUT should contain:
785785
"""
786786
:1234567890123456789éhttps:
@@ -794,7 +794,7 @@ Feature: Search through the database
794794
[...]
795795
"""
796796

797-
When I run `wp db search 'htt(p(s):)\/\/' --regex --before_context=1 --after_context=3`
797+
When I run `wp db search "htt(p(s):)\/\/" --regex --before_context=1 --after_context=3`
798798
Then STDOUT should contain:
799799
"""
800800
:あhttps://reg [...] éhttps://reg
@@ -804,7 +804,7 @@ Feature: Search through the database
804804
rege
805805
"""
806806

807-
When I run `wp db search 'https://' --regex --regex-delimiter=# --before_context=9 --after_context=11`
807+
When I run `wp db search "https://" --regex --regex-delimiter=# --before_context=9 --after_context=11`
808808
Then STDOUT should contain:
809809
"""
810810
:2345é789あhttps://regextst.co [...] 23456789éhttps://regextst.co
@@ -814,10 +814,10 @@ Feature: Search through the database
814814
regextst.com
815815
"""
816816

817-
When I run `wp db search 'httPs://' --regex --regex-delimiter=# --before_context=3 --after_context=0`
817+
When I run `wp db search "httPs://" --regex --regex-delimiter=# --before_context=3 --after_context=0`
818818
Then STDOUT should be empty
819819

820-
When I run `wp db search 'httPs://' --regex --regex-flags=i --regex-delimiter=# --before_context=3 --after_context=0`
820+
When I run `wp db search "httPs://" --regex --regex-flags=i --regex-delimiter=# --before_context=3 --after_context=0`
821821
Then STDOUT should contain:
822822
"""
823823
:89あhttps:// [...] 89éhttps://
@@ -827,19 +827,19 @@ Feature: Search through the database
827827
https://r
828828
"""
829829

830-
When I run `wp db search 'ppppp' --regex --before_context=3 --after_context=4`
830+
When I run `wp db search "ppppp" --regex --before_context=3 --after_context=4`
831831
Then STDOUT should contain:
832832
"""
833833
:ムnöppppp
834834
"""
835835

836-
When I run `wp db search 'ppppp' --regex --before_context=1 --after_context=1`
836+
When I run `wp db search "ppppp" --regex --before_context=1 --after_context=1`
837837
Then STDOUT should contain:
838838
"""
839839
:öppppp
840840
"""
841841

842-
When I run `wp db search 'ムn' --before_context=2 --after_context=1`
842+
When I run `wp db search "ムn" --before_context=2 --after_context=1`
843843
Then STDOUT should contain:
844844
"""
845845
:llムnö
@@ -849,7 +849,7 @@ Feature: Search through the database
849849
:llムnöp
850850
"""
851851

852-
When I run `wp db search 'ムn' --regex --before_context=2 --after_context=2`
852+
When I run `wp db search "ムn" --regex --before_context=2 --after_context=2`
853853
Then STDOUT should contain:
854854
"""
855855
:llムnöp
@@ -859,7 +859,7 @@ Feature: Search through the database
859859
:llムnöpp
860860
"""
861861

862-
When I run `wp db search 't\.c' --regex --before_context=1 --after_context=1`
862+
When I run `wp db search "t\.c" --regex --before_context=1 --after_context=1`
863863
Then STDOUT should contain:
864864
"""
865865
:st.co [...] st.co [...] st.co [...] 0t.co
@@ -869,7 +869,7 @@ Feature: Search through the database
869869
st.com
870870
"""
871871

872-
When I run `wp db search 'https://' --regex`
872+
When I run `wp db search "https://" --regex`
873873
Then the return code should be 0
874874

875875
Scenario: Search with output options
@@ -982,6 +982,7 @@ Feature: Search through the database
982982
And STDOUT should match /\d tables? skipped:.*wp_term_relationships/
983983
And STDERR should be empty
984984

985+
@skip-windows
985986
Scenario: Search with custom colors
986987
Given a WP install
987988

@@ -1060,7 +1061,7 @@ Feature: Search through the database
10601061
When I run `wp db query "SOURCE esc_sql_ident.sql;"`
10611062
Then STDERR should be empty
10621063

1063-
When I run `wp db search 'v_v' TABLE --all-tables`
1064+
When I run `wp db search "v_v" TABLE --all-tables`
10641065
Then STDOUT should be:
10651066
"""
10661067
TABLE:VALUES

features/db-size.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Feature: Display database size
3232
B
3333
"""
3434

35+
# On CI, SQLite on Windows is missing the dbstat extension.
36+
@skip-windows
3537
Scenario: Display only table sizes for a WordPress install
3638
Given a WP install
3739

@@ -81,6 +83,8 @@ Feature: Display database size
8183
KB
8284
"""
8385

86+
# On CI, SQLite on Windows is missing the dbstat extension.
87+
@skip-windows
8488
Scenario: Display only table sizes in a human readable format for a WordPress install
8589
Given a WP install
8690

@@ -222,6 +226,8 @@ Feature: Display database size
222226

223227
But STDOUT should not be a number
224228

229+
# On CI, SQLite on Windows is missing the dbstat extension.
230+
@skip-windows
225231
Scenario: Display all table sizes for a WordPress install
226232
Given a WP install
227233

@@ -282,6 +288,8 @@ Feature: Display database size
282288
[{"Name":"wp_posts",
283289
"""
284290

291+
# On CI, SQLite on Windows is missing the dbstat extension.
292+
@skip-windows
285293
Scenario: Display ordered table sizes for a WordPress install
286294
Given a WP install
287295

features/db.feature

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Feature: Perform database operations
256256
1
257257
"""
258258
259-
When I run `wp db export /tmp/wp-cli-behat.sql`
259+
When I run `wp db export wp-cli-behat.sql`
260260
Then STDOUT should contain:
261261
"""
262262
Success: Exported
@@ -283,7 +283,7 @@ Feature: Perform database operations
283283
When I try `wp post list --format=count`
284284
Then STDERR should not be empty
285285
286-
When I run `wp db import /tmp/wp-cli-behat.sql`
286+
When I run `wp db import wp-cli-behat.sql`
287287
Then STDOUT should contain:
288288
"""
289289
Success: Imported
@@ -312,7 +312,7 @@ Feature: Perform database operations
312312
When I run `wp db create`
313313
Then STDOUT should not be empty
314314
315-
When I run `wp db export /tmp/wp-cli-behat.sql`
315+
When I run `wp db export wp-cli-behat.sql`
316316
Then STDOUT should contain:
317317
"""
318318
Success: Exported
@@ -383,7 +383,8 @@ Feature: Perform database operations
383383
Query succeeded. Rows affected: 1
384384
"""
385385
386-
@require-sqlite
386+
@require-sqlite @skip-windows
387+
# Skipped on Windows due to persistent file locking issues when run via Behat.
387388
Scenario: SQLite DB CRUD operations
388389
Given a WP install
389390
And a session_yes file:
@@ -420,7 +421,8 @@ Feature: Perform database operations
420421
total
421422
"""
422423
423-
@require-sqlite
424+
@require-sqlite @skip-windows
425+
# Skipped on Windows due to persistent file locking issues when run via Behat.
424426
Scenario: SQLite DB export/import
425427
Given a WP install
426428
And a session_yes file:
@@ -434,7 +436,7 @@ Feature: Perform database operations
434436
1
435437
"""
436438
437-
When I run `wp db export /tmp/wp-cli-sqlite-behat.sql`
439+
When I run `wp db export wp-cli-sqlite-behat.sql`
438440
Then STDOUT should contain:
439441
"""
440442
Success: Exported
@@ -446,7 +448,7 @@ Feature: Perform database operations
446448
Success: Database reset
447449
"""
448450
449-
When I run `wp db import /tmp/wp-cli-sqlite-behat.sql`
451+
When I run `wp db import wp-cli-sqlite-behat.sql`
450452
Then STDOUT should contain:
451453
"""
452454
Success: Imported

0 commit comments

Comments
 (0)