[6.x] Fix Glide tag erroring when an asset cannot be resolved - #15360
Open
lazerg wants to merge 2 commits into
Open
[6.x] Fix Glide tag erroring when an asset cannot be resolved#15360lazerg wants to merge 2 commits into
lazerg wants to merge 2 commits into
Conversation
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.
When the Glide tag is given an asset that can't be resolved, the tag 500s the whole page instead of skipping the image.
normalizeItem()returns null for an unresolvable asset ID, and that null then reachesImageGenerator::generateByAsset(), which callsisVideo()on it, orAsset::find(), which rejects it against itsstringsignature. Both are an\Errorrather than an\Exception, so they slip past thecatch (\Exception)inGlide::generate(). There are three ways to hit this today: the plain unresolvable ID, the same ID withfit="crop_focal", and the same ID when the cache disk has a URL so images are served directly.Every other failure inside that closure degrades gracefully, so these should too.
normalizeItem()now keeps the original ID when it can't resolve it, which is what it already does for the URL branch a few lines down, andgenerateImage()throws anAssetNotFoundExceptionwhen there's still no asset. The existing catch logs it and the image is skipped. That mirrors the guardStaticUrlBuilder::generatePath()already has for the same situation.Keeping the ID also cleans up the single tag form,
{{ glide src="..." }}without a closing tag. That one only builds a URL, so it never crashed, but it was passing the null down intorawurlencode()and triggering a deprecation on the way to a/img?w=100URL with no image in it.Fixes #15359