Repository navigation
Conversation
This branch has not been deployed
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.
Skip the image driver's format check for JPG, JPEG, PNG and GIF in
ImageValidator::isValidExtension().Problem
With the Imagick driver,
$driver->supports($extension)callsImagick::queryFormats(). The first call in a PHP process takes a good 400ms while ImageMagick loads its format modules.The memo from #15449 only helps within a single request, because the memoized static property is reset after each one. The check is still done by every artisan command,
queue:listenjob,static:warmrun and test run, and on the first request in each PHP-FPM worker.Fix
GD and Imagick can both read JPG, JPEG, PNG and GIF, so
isValidExtension()now returnstruefor those without asking the driver. Most calls are for these formats, so requests not generating WEBP or AVIF urls should never pay the ImageMagick format check at all. Other extensions (webp, avif, svg, heic, tiff, pdf, …) still go through the driver check and the memo.isValidImage()still checks the MIME type for every extension.Trade-off
A GD or ImageMagick build without JPEG/PNG support would now report those formats as valid. I'm pretty sure that's not a realistic setup in the wild, though :) Debian, Ubuntu, Homebrew all have those formats enabled, and Forge, Ploi, Plesk all install from those packages. GIF support is hardwired into both, interestingly.
Tests
supports()is never called forjpg,JPG,jpeg,pngandgif, and all of them returntruenullextensions still returnfalse