From 00f13be88d1297f1c2756e13427f407240a13442 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:34:56 +0000 Subject: [PATCH 1/9] Initial plan From 0671eb593914e75e16ba3d515c60a58c95033863 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:40:33 +0000 Subject: [PATCH 2/9] Add helpful tip when core update is locked Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/core-update.feature | 29 +++++++++++++++++++++++++++++ src/Core_Command.php | 7 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/features/core-update.feature b/features/core-update.feature index a52bcd3b..6138de5b 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -384,3 +384,32 @@ Feature: Update WordPress core """ Success: """ + + Scenario: Show helpful tip when update is locked + Given a WP install + + # Create a lock option to simulate another update in progress + When I run `wp option add core_updater.lock 1` + Then STDOUT should contain: + """ + Success: + """ + + # Try to update and expect the lock error with helpful tip + When I try `wp core update --version=latest` + Then STDERR should contain: + """ + wp option delete core_updater.lock + """ + And STDERR should contain: + """ + another update + """ + And the return code should be 1 + + # Clean up the lock + When I run `wp option delete core_updater.lock` + Then STDOUT should contain: + """ + Success: + """ diff --git a/src/Core_Command.php b/src/Core_Command.php index b9bbb2b4..1add298f 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1234,7 +1234,12 @@ public function update( $args, $assoc_args ) { if ( is_wp_error( $result ) ) { $message = WP_CLI::error_to_string( $result ); if ( 'up_to_date' !== $result->get_error_code() ) { - WP_CLI::error( $message ); + // Check if the error is related to the core_updater.lock + if ( 'locked' === $result->get_error_code() || false !== stripos( $message, 'another update is currently in progress' ) ) { + WP_CLI::error( $message . ' You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.' ); + } else { + WP_CLI::error( $message ); + } } else { WP_CLI::success( $message ); } From 4fad4a5ab5ce2c8779099541695814dd9b310480 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:45:06 +0000 Subject: [PATCH 3/9] Refactor lock error detection with helper method and constant Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Core_Command.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 1add298f..47367e6d 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -31,6 +31,11 @@ */ class Core_Command extends WP_CLI_Command { + /** + * Tip message for resolving the core_updater.lock issue. + */ + const LOCK_TIP_MESSAGE = 'You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.'; + /** * Checks for WordPress updates via Version Check API. * @@ -1235,8 +1240,8 @@ public function update( $args, $assoc_args ) { $message = WP_CLI::error_to_string( $result ); if ( 'up_to_date' !== $result->get_error_code() ) { // Check if the error is related to the core_updater.lock - if ( 'locked' === $result->get_error_code() || false !== stripos( $message, 'another update is currently in progress' ) ) { - WP_CLI::error( $message . ' You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.' ); + if ( self::is_lock_error( $result ) ) { + WP_CLI::error( $message . ' ' . self::LOCK_TIP_MESSAGE ); } else { WP_CLI::error( $message ); } @@ -1668,4 +1673,25 @@ function () use ( $new_zip_file ) { WP_CLI::error( 'ZipArchive failed to open ZIP file.' ); } } + + /** + * Checks if a WP_Error is related to the core_updater.lock. + * + * @param WP_Error $error The error object to check. + * @return bool True if the error is related to the lock, false otherwise. + */ + private static function is_lock_error( $error ) { + if ( ! is_wp_error( $error ) ) { + return false; + } + + // Check for the 'locked' error code used by WordPress Core + if ( 'locked' === $error->get_error_code() ) { + return true; + } + + // Also check if the error message contains the lock text as a fallback + $message = WP_CLI::error_to_string( $error ); + return false !== stripos( $message, 'another update is currently in progress' ); + } } From 187bb76b8b7592c6da9c47b298cb4632c2ce2a0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:46:51 +0000 Subject: [PATCH 4/9] Address code review feedback: improve constant naming and formatting Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Core_Command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 47367e6d..e8a7ea13 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -34,7 +34,7 @@ class Core_Command extends WP_CLI_Command { /** * Tip message for resolving the core_updater.lock issue. */ - const LOCK_TIP_MESSAGE = 'You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.'; + const CORE_UPDATER_LOCK_TIP = 'You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.'; /** * Checks for WordPress updates via Version Check API. @@ -1241,7 +1241,7 @@ public function update( $args, $assoc_args ) { if ( 'up_to_date' !== $result->get_error_code() ) { // Check if the error is related to the core_updater.lock if ( self::is_lock_error( $result ) ) { - WP_CLI::error( $message . ' ' . self::LOCK_TIP_MESSAGE ); + WP_CLI::error( rtrim( $message, '.' ) . '. ' . self::CORE_UPDATER_LOCK_TIP ); } else { WP_CLI::error( $message ); } @@ -1677,7 +1677,7 @@ function () use ( $new_zip_file ) { /** * Checks if a WP_Error is related to the core_updater.lock. * - * @param WP_Error $error The error object to check. + * @param \WP_Error $error The error object to check. * @return bool True if the error is related to the lock, false otherwise. */ private static function is_lock_error( $error ) { From 92992bdf9c01fab11a4b4c530987a30cf0b33751 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:10:49 +0000 Subject: [PATCH 5/9] Remove constant and use inline text for lock tip message Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Core_Command.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index e8a7ea13..78626dea 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -31,11 +31,6 @@ */ class Core_Command extends WP_CLI_Command { - /** - * Tip message for resolving the core_updater.lock issue. - */ - const CORE_UPDATER_LOCK_TIP = 'You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.'; - /** * Checks for WordPress updates via Version Check API. * @@ -1241,7 +1236,7 @@ public function update( $args, $assoc_args ) { if ( 'up_to_date' !== $result->get_error_code() ) { // Check if the error is related to the core_updater.lock if ( self::is_lock_error( $result ) ) { - WP_CLI::error( rtrim( $message, '.' ) . '. ' . self::CORE_UPDATER_LOCK_TIP ); + WP_CLI::error( rtrim( $message, '.' ) . '. You may need to run `wp option delete core_updater.lock` after verifying another update isn\'t actually running.' ); } else { WP_CLI::error( $message ); } From 18ebbbba94c0bc0aebb381ff9bb7561fbece5a74 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:13:17 +0000 Subject: [PATCH 6/9] Update test to verify full error message with lock tip Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/core-update.feature | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/features/core-update.feature b/features/core-update.feature index 6138de5b..9a10b6b5 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -399,11 +399,7 @@ Feature: Update WordPress core When I try `wp core update --version=latest` Then STDERR should contain: """ - wp option delete core_updater.lock - """ - And STDERR should contain: - """ - another update + 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. """ And the return code should be 1 From 2623e48fd81be7d9ec009a9d5e2796f4d8909f18 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:33:13 +0000 Subject: [PATCH 7/9] Remove superfluous is_wp_error check from is_lock_error method Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Core_Command.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 78626dea..71724aba 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1676,10 +1676,6 @@ function () use ( $new_zip_file ) { * @return bool True if the error is related to the lock, false otherwise. */ private static function is_lock_error( $error ) { - if ( ! is_wp_error( $error ) ) { - return false; - } - // Check for the 'locked' error code used by WordPress Core if ( 'locked' === $error->get_error_code() ) { return true; From 1862db61ea4ef37de1077fb37f9ac6734364953f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 5 Nov 2025 16:15:17 +0100 Subject: [PATCH 8/9] Simplify test --- features/core-update.feature | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/features/core-update.feature b/features/core-update.feature index 9a10b6b5..a0f40c0e 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -390,13 +390,7 @@ Feature: Update WordPress core # Create a lock option to simulate another update in progress When I run `wp option add core_updater.lock 1` - Then STDOUT should contain: - """ - Success: - """ - - # Try to update and expect the lock error with helpful tip - When I try `wp core update --version=latest` + And I try `wp core update --version=latest` Then STDERR should contain: """ 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. From 7e15ff0918d08c6a859429bbcabe43dc7b14c66a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 5 Nov 2025 19:21:03 +0100 Subject: [PATCH 9/9] Simplify and fix test --- features/core-update.feature | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/features/core-update.feature b/features/core-update.feature index a0f40c0e..6e1fb8ab 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -388,9 +388,8 @@ Feature: Update WordPress core Scenario: Show helpful tip when update is locked Given a WP install - # Create a lock option to simulate another update in progress - When I run `wp option add core_updater.lock 1` - And I try `wp core update --version=latest` + When I run `wp option update core_updater.lock 100000000000000` + And I try `wp core update --version=trunk` Then STDERR should contain: """ 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.