Skip to content

Commit 391bce4

Browse files
authored
Merge branch 'main' into copilot/fix-wp-core-check-update-issue
2 parents 49deb66 + 2b1add2 commit 391bce4

File tree

8 files changed

+69
-5
lines changed

8 files changed

+69
-5
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
@@ -239,6 +239,8 @@ Transforms an existing single-site installation into a multisite installation.
239239
wp core multisite-convert [--title=<network-title>] [--base=<url-path>] [--subdomains] [--skip-config]
240240
~~~
241241

242+
**Alias:** `install-network`
243+
242244
Creates the multisite database tables, and adds the multisite constants
243245
to wp-config.php.
244246

@@ -344,6 +346,8 @@ Updates WordPress to a newer version.
344346
wp core update [<zip>] [--minor] [--version=<version>] [--force] [--locale=<locale>] [--format=<format>] [--insecure]
345347
~~~
346348

349+
**Alias:** `upgrade`
350+
347351
Defaults to updating WordPress to the latest version.
348352

349353
If you see "Error: Another update is currently in progress.", you may

features/core-update.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,21 @@ Feature: Update WordPress core
419419
"""
420420
</div>
421421
"""
422+
423+
Scenario: Show helpful tip when update is locked
424+
Given a WP install
425+
426+
When I run `wp option update core_updater.lock 100000000000000`
427+
And I try `wp core update --version=trunk`
428+
Then STDERR should contain:
429+
"""
430+
Another update is currently in progress. You may need to run `wp option delete core_updater.lock` after verifying another update isn't actually running.
431+
"""
432+
And the return code should be 1
433+
434+
# Clean up the lock
435+
When I run `wp option delete core_updater.lock`
436+
Then STDOUT should contain:
437+
"""
438+
Success:
439+
"""

src/Core_Command.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,12 @@ static function () {
12581258
if ( is_wp_error( $result ) ) {
12591259
$message = WP_CLI::error_to_string( $result );
12601260
if ( 'up_to_date' !== $result->get_error_code() ) {
1261-
WP_CLI::error( $message );
1261+
// Check if the error is related to the core_updater.lock
1262+
if ( self::is_lock_error( $result ) ) {
1263+
WP_CLI::error( rtrim( $message, '.' ) . '. You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.' );
1264+
} else {
1265+
WP_CLI::error( $message );
1266+
}
12621267
} else {
12631268
WP_CLI::success( $message );
12641269
}
@@ -1727,4 +1732,21 @@ function () use ( $new_zip_file ) {
17271732
WP_CLI::error( 'ZipArchive failed to open ZIP file.' );
17281733
}
17291734
}
1735+
1736+
/**
1737+
* Checks if a WP_Error is related to the core_updater.lock.
1738+
*
1739+
* @param \WP_Error $error The error object to check.
1740+
* @return bool True if the error is related to the lock, false otherwise.
1741+
*/
1742+
private static function is_lock_error( $error ) {
1743+
// Check for the 'locked' error code used by WordPress Core
1744+
if ( 'locked' === $error->get_error_code() ) {
1745+
return true;
1746+
}
1747+
1748+
// Also check if the error message contains the lock text as a fallback
1749+
$message = WP_CLI::error_to_string( $error );
1750+
return false !== stripos( $message, 'another update is currently in progress' );
1751+
}
17301752
}

0 commit comments

Comments
 (0)