Skip to content

Commit 6443609

Browse files
committed
Merge branch 'main' into copilot/add-delete-old-core-files
2 parents 71a888f + 8641c45 commit 6443609

File tree

7 files changed

+356
-53
lines changed

7 files changed

+356
-53
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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@3cf229dc2919194e9e36783941438d17239e8520 # v3
41+
uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -177,50 +177,21 @@ Feature: Install WordPress core
177177
"""
178178
And the return code should be 0
179179
180-
@less-than-php-7
181-
Scenario: Install WordPress with locale set to de_DE on WP < 4.0
180+
Scenario: Install WordPress with special characters in the admin password
182181
Given an empty directory
183-
And an empty cache
182+
And WP files
183+
And wp-config.php
184184
And a database
185185
186-
When I run `wp core download --version=3.7 --locale=de_DE`
187-
And save STDOUT 'Downloading WordPress ([\d\.]+)' as {VERSION}
188-
And I run `echo {VERSION}`
186+
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`
189187
Then STDOUT should contain:
190-
"""
191-
3.7
192-
"""
193-
And the wp-settings.php file should exist
194-
And the {SUITE_CACHE_DIR}/core/wordpress-{VERSION}-de_DE.tar.gz file should exist
195-
196-
When I run `wp config create --dbname={DB_NAME} --dbuser={DB_USER} --dbpass={DB_PASSWORD} --dbhost={DB_HOST} --locale=de_DE --skip-check`
197-
Then STDOUT should be:
198-
"""
199-
Success: Generated 'wp-config.php' file.
200-
"""
201-
202-
# Old versions of WP can generate wpdb database errors if the WP tables don't exist, so STDERR may or may not be empty
203-
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`
204-
Then STDERR should contain:
205-
"""
206-
Warning: The flag --locale=de_DE is being ignored as it requires WordPress 4.0+.
207-
"""
208-
And STDOUT should contain:
209188
"""
210189
Success: WordPress installed successfully.
211190
"""
191+
And the return code should be 0
212192
213-
When I run `wp core version`
214-
Then STDOUT should contain:
215-
"""
216-
3.7
217-
"""
218-
219-
When I run `wp taxonomy list`
220-
Then STDOUT should contain:
221-
"""
222-
Kategorien
223-
"""
193+
When I run `wp user check-password wpcli 'R^^CzY;G"iZ@]H9b,' --escape-chars`
194+
Then the return code should be 0
224195
225196
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
226197
@require-mysql

features/core-update.feature

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ Feature: Update WordPress core
420420
</div>
421421
"""
422422

423-
@require-php-7.2
424423
Scenario: Old files from $_old_files are cleaned up when upgrading
425424
Given a WP install
426425

@@ -505,7 +504,72 @@ Feature: Update WordPress core
505504
And the wp-includes/blocks/post-author/editor.css file should not exist
506505
And the wp-includes/blocks/post-author/editor.min.css file should not exist
507506

508-
@require-php-7.0 @require-wp-6.1
507+
Scenario: Update WordPress locale without --force when version is the same
508+
Given a WP install
509+
And an empty cache
510+
511+
# Using `try` in case there are checksum warnings.
512+
When I try `wp core download --version=6.5 --locale=de_DE --force`
513+
Then STDOUT should contain:
514+
"""
515+
Success: WordPress downloaded.
516+
"""
517+
518+
When I run `wp core version --extra`
519+
Then STDOUT should contain:
520+
"""
521+
Package language: de_DE
522+
"""
523+
524+
When I run `wp core version`
525+
Then save STDOUT as {CURRENT_VERSION}
526+
527+
# Updating to the same version with a different locale should work without --force.
528+
When I run `wp core update --version={CURRENT_VERSION} --locale=en_US`
529+
Then STDOUT should contain:
530+
"""
531+
Updating to version {CURRENT_VERSION} (en_US)...
532+
"""
533+
And STDOUT should contain:
534+
"""
535+
Success: WordPress updated successfully.
536+
"""
537+
538+
When I run `wp core version --extra`
539+
Then STDOUT should contain:
540+
"""
541+
Package language: en_US
542+
"""
543+
544+
Scenario: Update WordPress locale when using --minor
545+
Given a WP install
546+
And an empty cache
547+
548+
# Using `try` in case there are checksum warnings.
549+
When I try `wp core download --version=6.5 --locale=de_DE --force`
550+
Then STDOUT should contain:
551+
"""
552+
Success: WordPress downloaded.
553+
"""
554+
555+
When I run `wp core version --extra`
556+
Then STDOUT should contain:
557+
"""
558+
Package language: de_DE
559+
"""
560+
561+
When I run `wp core update --minor --locale=en_US`
562+
Then STDOUT should contain:
563+
"""
564+
Success: WordPress updated successfully.
565+
"""
566+
567+
When I run `wp core version --extra`
568+
Then STDOUT should contain:
569+
"""
570+
Package language: en_US
571+
"""
572+
@require-wp-6.1
509573
Scenario: Attempting to downgrade without --force shows helpful message
510574
Given a WP install
511575

0 commit comments

Comments
 (0)