fix(cli): avoid phar autoload during self-update#1926
Merged
mrrobot47 merged 1 commit intoJul 7, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a failure mode in ee cli update where the self-update could abort due to autoloading php-cli-tools classes from the currently running (and potentially broken) phar after the phar replacement step.
Changes:
- Computes the “updated version” message and captures
--quietstate before replacing the running phar. - Removes forced autoloading of
\cli\Streams/\cli\Colorsprior to replacement. - Emits the final success message via plain
fwrite(STDOUT, ...)after replacement (and only when not quiet), avoiding logger/color autoloads.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a self-update failure where
ee cli updatecan successfully download and verify the new phar, but then fail after replacement with a PHP parse error fromvendor/wp-cli/php-cli-tools/lib/cli/Streams.php.The updater previously forced
cli\Streamsandcli\Colorsto autoload immediately before replacing the running phar. If the currently installed phar has a broken or incompatibleStreams.php, the update can fail even though the downloaded phar is valid.This change avoids phar-backed logger/color autoloads after replacement by:
--quietbehavior before replacementfwrite()after replacement