Repository navigation
fix(phar): convert extractTo warnings to RuntimeException and keep rollback under throwing error handlers - #1201
Open
rootsiemen wants to merge 1 commit into
Open
rootsiemen wants to merge 1 commit into
rootsiemen wants to merge 1 commit into
Conversation
…llback under throwing error handlers Closes crazy-goat#1181
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.
Closes #1181
ZipArchive::extractTo()emits anE_WARNINGon failure. With a strict error handler installed (e.g. Symfony ErrorHandler, which throwsErrorException), the warning bypassed thecatch (\RuntimeException)rollback inextractToDirectory()and the archive cleanup infetch(), so a failed extraction left the pre-extracted entries and the bad archive on disk.extractToDirectory()now suppresses the warning with@and converts the failure into aRuntimeExceptionthat names the entry and carries the underlying warning text (same idiom aswriteStream()).extractToDirectory()andfetch()are widened to\Throwableand rethrow, so rollback and archive removal still happen even if a handler throws despite the suppression.@fetch(); they run through arunWithoutWarningLeak()helper that fails if any warning escapesfetch().testExtractZipRollsBackAndRemovesArchiveUnderThrowingErrorHandlerinstalls an unconditionally throwing handler and asserts the failed archive is removed and the earlier entry is rolled back (verified to fail on the old code: the archive stayed on disk).Verified locally:
tests/Phar/SfxDownloaderTest.php69 tests green,composer lintgreen except pre-existingshellcheck(untouchedbin/worktree-done.sh) and missinghadolintin this environment.