Skip to content

Fix: auto update check error should not fail the running command#6345

Open
swissspidy with Copilot wants to merge 5 commits into
mainfrom
copilot/auto-update-check-warning
Open

Fix: auto update check error should not fail the running command#6345
swissspidy with Copilot wants to merge 5 commits into
mainfrom
copilot/auto-update-check-warning

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

When the background update check hits a network/HTTP error (e.g. 401, 403 rate-limit), CLI_Command::get_updates() calls WP_CLI::error(), which exits the process — silently killing whatever command the user actually ran.

Changes

  • Runner::auto_check_update(): Replace the bare ob_start() / WP_CLI::run_command() pattern with WP_CLI::runcommand() using exit_error => false and return => 'all'
    • exit_error => false sets $capture_exit = true so WP_CLI::error() throws ExitException instead of calling exit()
    • return => 'all' swaps in an Execution logger that captures stdout/stderr in memory — the error message is never printed to the terminal
    • On failure, a WP_CLI::debug() message is emitted (visible with --debug) and the check silently returns without affecting the user's command
// Before: any HTTP error in get_updates() would call exit(1)
ob_start();
WP_CLI::run_command( [ 'cli', 'check-update' ], [ 'format' => 'count' ] );
$count = ob_get_clean();

// After: errors are captured, not propagated
$result = WP_CLI::runcommand(
    'cli check-update --format=count',
    [ 'launch' => false, 'exit_error' => false, 'return' => 'all' ]
);
if ( ! is_object( $result ) || $result->return_code ) {
    WP_CLI::debug( 'Background update check failed: ' . ( is_object( $result ) ? trim( $result->stderr ) : '' ), 'auto-update' );
    return;
}

Summary by CodeRabbit

  • Bug Fixes
    • Prevented automatic update checks from disrupting unrelated CLI commands when the releases service is rate-limited or unreachable.
    • Improved resilience of background update detection so failures no longer cause non-update commands to exit non-zero.
  • Tests
    • Added coverage for the “rate limit exceeded” case and confirmed update checks don’t affect commands like wp help, including when auto-check timing is disabled.

@coderabbitai

This comment was marked as resolved.

Copilot AI linked an issue Jul 16, 2026 that may be closed by this pull request
@github-actions github-actions Bot added bug command:cli-check-update Related to 'cli check-update' command command:cli-update Related to 'cli update' command labels Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Runner.php 0.00% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

Use WP_CLI::runcommand() with exit_error=>false and return=>'all'
in Runner::auto_check_update() so that HTTP/network errors during
the background update check are silently captured (logged at debug
level) instead of propagating and failing the user's command.

Closes #6344

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix auto update check error on command failure Fix: auto update check error should not fail the running command Jul 16, 2026
Copilot AI requested a review from swissspidy July 16, 2026 13:46
@swissspidy
swissspidy requested a review from Copilot July 16, 2026 15:22

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy
swissspidy marked this pull request as ready for review July 16, 2026 15:39
@swissspidy
swissspidy requested a review from a team as a code owner July 16, 2026 15:39
coderabbitai[bot]

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@swissspidy swissspidy added this to the 3.0.0 milestone Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:cli-check-update Related to 'cli check-update' command command:cli-update Related to 'cli update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto update check error should not fail command

3 participants