Skip to content

Commit 9df1c39

Browse files
committed
Merge branch 'main' into copilot/fix-core-install-home-siteurl
2 parents ef8c6fb + 1445c14 commit 9df1c39

File tree

9 files changed

+428
-65
lines changed

9 files changed

+428
-65
lines changed

.github/workflows/code-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ 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'
@@ -38,7 +36,7 @@ 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@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3
4240
env:
4341
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4442
with:

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,34 @@ or success message when up to date.
8888

8989

9090

91+
### wp core check-update-db
92+
93+
Checks for the need for WordPress database updates.
94+
95+
~~~
96+
wp core check-update-db [--network]
97+
~~~
98+
99+
Compares the current database version with the version required by WordPress core
100+
to determine if database updates are needed.
101+
102+
**OPTIONS**
103+
104+
[--network]
105+
Check databases for all sites on a network.
106+
107+
**EXAMPLES**
108+
109+
# Check if database update is needed
110+
$ wp core check-update-db
111+
Success: WordPress database is up to date.
112+
113+
# Check database update status for all sites on a network
114+
$ wp core check-update-db --network
115+
Success: WordPress databases are up to date on 5/5 sites.
116+
117+
118+
91119
### wp core download
92120

93121
Downloads core WordPress files.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"composer/semver": "^1.4 || ^2 || ^3",
16-
"wp-cli/wp-cli": "^2.12"
16+
"wp-cli/wp-cli": "^2.13"
1717
},
1818
"require-dev": {
1919
"wp-cli/checksum-command": "^1 || ^2",
@@ -40,6 +40,7 @@
4040
"commands": [
4141
"core",
4242
"core check-update",
43+
"core check-update-db",
4344
"core download",
4445
"core install",
4546
"core is-installed",
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Feature: Check if WordPress database update is needed
2+
3+
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
4+
@require-mysql
5+
Scenario: Check if database update is needed on a single site
6+
Given a WP install
7+
And a disable_sidebar_check.php file:
8+
"""
9+
<?php
10+
WP_CLI::add_wp_hook( 'init', static function () {
11+
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
12+
} );
13+
"""
14+
And I try `wp theme install twentytwenty --activate`
15+
And I run `wp core download --version=5.4 --force`
16+
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
17+
18+
When I try `wp core check-update-db`
19+
Then the return code should be 1
20+
And STDOUT should contain:
21+
"""
22+
WordPress database update required from db version 45805 to 47018.
23+
"""
24+
25+
When I run `wp core update-db`
26+
Then STDOUT should contain:
27+
"""
28+
Success: WordPress database upgraded successfully from db version 45805 to 47018.
29+
"""
30+
31+
When I run `wp core check-update-db`
32+
Then STDOUT should contain:
33+
"""
34+
Success: WordPress database is up to date.
35+
"""
36+
37+
Scenario: Check if database update is needed when database is already up to date
38+
Given a WP install
39+
40+
When I run `wp core check-update-db`
41+
Then STDOUT should contain:
42+
"""
43+
Success: WordPress database is up to date.
44+
"""
45+
46+
Scenario: Check if database update is needed across network
47+
Given a WP multisite install
48+
And a disable_sidebar_check.php file:
49+
"""
50+
<?php
51+
WP_CLI::add_wp_hook( 'init', static function () {
52+
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
53+
} );
54+
"""
55+
And I try `wp theme install twentytwenty --activate`
56+
And I run `wp core download --version=6.6 --force`
57+
And I run `wp option update db_version 57155 --require=disable_sidebar_check.php`
58+
And I run `wp site option update wpmu_upgrade_site 57155`
59+
And I run `wp site create --slug=foo`
60+
And I run `wp site create --slug=bar`
61+
And I run `wp site create --slug=burrito --porcelain`
62+
And save STDOUT as {BURRITO_ID}
63+
And I run `wp site create --slug=taco --porcelain`
64+
And save STDOUT as {TACO_ID}
65+
And I run `wp site create --slug=pizza --porcelain`
66+
And save STDOUT as {PIZZA_ID}
67+
And I run `wp site archive {BURRITO_ID}`
68+
And I run `wp site spam {TACO_ID}`
69+
And I run `wp site delete {PIZZA_ID} --yes`
70+
And I run `wp core update`
71+
72+
When I try `wp core check-update-db --network`
73+
Then the return code should be 1
74+
And STDOUT should contain:
75+
"""
76+
WordPress database update needed on 3/3 sites:
77+
"""
78+
79+
When I run `wp core update-db --network`
80+
Then STDOUT should contain:
81+
"""
82+
Success: WordPress database upgraded on 3/3 sites.
83+
"""
84+
85+
When I run `wp core check-update-db --network`
86+
Then STDOUT should contain:
87+
"""
88+
Success: WordPress databases are up to date on 3/3 sites.
89+
"""
90+
91+
Scenario: Check database update on network installation errors on single site
92+
Given a WP install
93+
94+
When I try `wp core check-update-db --network`
95+
Then STDERR should contain:
96+
"""
97+
Error: This is not a multisite installation.
98+
"""
99+
And the return code should be 1

features/core-install.feature

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -249,50 +249,21 @@ Feature: Install WordPress core
249249
https://example.com
250250
"""
251251
252-
@less-than-php-7
253-
Scenario: Install WordPress with locale set to de_DE on WP < 4.0
252+
Scenario: Install WordPress with special characters in the admin password
254253
Given an empty directory
255-
And an empty cache
254+
And WP files
255+
And wp-config.php
256256
And a database
257257
258-
When I run `wp core download --version=3.7 --locale=de_DE`
259-
And save STDOUT 'Downloading WordPress ([\d\.]+)' as {VERSION}
260-
And I run `echo {VERSION}`
258+
When I run `wp core install --url=localhost:8001 --title=Test --admin_user=wpcli --admin_email=wpcli@example.org --admin_password='R^^CzY;G"iZ@]H9b,' --skip-email`
261259
Then STDOUT should contain:
262-
"""
263-
3.7
264-
"""
265-
And the wp-settings.php file should exist
266-
And the {SUITE_CACHE_DIR}/core/wordpress-{VERSION}-de_DE.tar.gz file should exist
267-
268-
When I run `wp config create --dbname={DB_NAME} --dbuser={DB_USER} --dbpass={DB_PASSWORD} --dbhost={DB_HOST} --locale=de_DE --skip-check`
269-
Then STDOUT should be:
270-
"""
271-
Success: Generated 'wp-config.php' file.
272-
"""
273-
274-
# Old versions of WP can generate wpdb database errors if the WP tables don't exist, so STDERR may or may not be empty
275-
When I try `wp core install --url=example.org --title=Test --admin_user=testadmin --admin_email=testadmin@example.com --admin_password=newpassword --locale=de_DE --skip-email`
276-
Then STDERR should contain:
277-
"""
278-
Warning: The flag --locale=de_DE is being ignored as it requires WordPress 4.0+.
279-
"""
280-
And STDOUT should contain:
281260
"""
282261
Success: WordPress installed successfully.
283262
"""
263+
And the return code should be 0
284264
285-
When I run `wp core version`
286-
Then STDOUT should contain:
287-
"""
288-
3.7
289-
"""
290-
291-
When I run `wp taxonomy list`
292-
Then STDOUT should contain:
293-
"""
294-
Kategorien
295-
"""
265+
When I run `wp user check-password wpcli 'R^^CzY;G"iZ@]H9b,' --escape-chars`
266+
Then the return code should be 0
296267
297268
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
298269
@require-mysql

features/core-update.feature

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Feature: Update WordPress core
167167
When I run `wp core update`
168168
Then STDOUT should contain:
169169
"""
170-
WordPress is up to date
170+
WordPress is up to date at version
171171
"""
172172
And STDOUT should not contain:
173173
"""
@@ -420,6 +420,107 @@ Feature: Update WordPress core
420420
</div>
421421
"""
422422

423+
Scenario: Update WordPress locale without --force when version is the same
424+
Given a WP install
425+
And an empty cache
426+
427+
# Using `try` in case there are checksum warnings.
428+
When I try `wp core download --version=6.5 --locale=de_DE --force`
429+
Then STDOUT should contain:
430+
"""
431+
Success: WordPress downloaded.
432+
"""
433+
434+
When I run `wp core version --extra`
435+
Then STDOUT should contain:
436+
"""
437+
Package language: de_DE
438+
"""
439+
440+
When I run `wp core version`
441+
Then save STDOUT as {CURRENT_VERSION}
442+
443+
# Updating to the same version with a different locale should work without --force.
444+
When I run `wp core update --version={CURRENT_VERSION} --locale=en_US`
445+
Then STDOUT should contain:
446+
"""
447+
Updating to version {CURRENT_VERSION} (en_US)...
448+
"""
449+
And STDOUT should contain:
450+
"""
451+
Success: WordPress updated successfully.
452+
"""
453+
454+
When I run `wp core version --extra`
455+
Then STDOUT should contain:
456+
"""
457+
Package language: en_US
458+
"""
459+
460+
Scenario: Update WordPress locale when using --minor
461+
Given a WP install
462+
And an empty cache
463+
464+
# Using `try` in case there are checksum warnings.
465+
When I try `wp core download --version=6.5 --locale=de_DE --force`
466+
Then STDOUT should contain:
467+
"""
468+
Success: WordPress downloaded.
469+
"""
470+
471+
When I run `wp core version --extra`
472+
Then STDOUT should contain:
473+
"""
474+
Package language: de_DE
475+
"""
476+
477+
When I run `wp core update --minor --locale=en_US`
478+
Then STDOUT should contain:
479+
"""
480+
Success: WordPress updated successfully.
481+
"""
482+
483+
When I run `wp core version --extra`
484+
Then STDOUT should contain:
485+
"""
486+
Package language: en_US
487+
"""
488+
@require-php-7.0 @require-wp-6.1
489+
Scenario: Attempting to downgrade without --force shows helpful message
490+
Given a WP install
491+
492+
When I run `wp core version`
493+
Then save STDOUT as {WP_CURRENT_VERSION}
494+
495+
When I try `wp core update --version=6.0`
496+
Then STDOUT should contain:
497+
"""
498+
WordPress is up to date at version
499+
"""
500+
And STDOUT should contain:
501+
"""
502+
is older than the current version
503+
"""
504+
And STDOUT should contain:
505+
"""
506+
Use --force to update anyway
507+
"""
508+
And STDOUT should not contain:
509+
"""
510+
Success:
511+
"""
512+
And the return code should be 0
513+
514+
When I run `wp core update --version=6.0 --force`
515+
Then STDOUT should contain:
516+
"""
517+
Updating to version 6.0
518+
"""
519+
And STDOUT should contain:
520+
"""
521+
Success: WordPress updated successfully.
522+
"""
523+
423524
Scenario: Show helpful tip when update is locked
424525
Given a WP install
425526

@@ -436,4 +537,4 @@ Feature: Update WordPress core
436537
Then STDOUT should contain:
437538
"""
438539
Success:
439-
"""
540+
"""

0 commit comments

Comments
 (0)