[6.x] Use a unique temporary path when reading image attributes - #15171
Merged
Conversation
`Imaging\Attributes` copies files off non-local disks so their dimensions can be read locally. The destination was the source path itself, so concurrent requests reading attributes for the same file would clobber and delete each other's copy, throwing `UnableToDeleteFile` or returning 0x0 dimensions. The local disk shortcut also assigned the source to `$cacheDisk`, which is memoized for the lifetime of the request. Any later non-local read then copied into that disk instead of the temporary one, writing into the site's asset container. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
This pull request fixes an issue where reading image attributes from a non-local disk could throw
Unable to delete file located at: cache://..., or return0x0dimensions.This was happening because
Imaging\Attributescopies files off non-local disks into a temporary local disk so their dimensions can be read locally, and the destination was the source path itself. Every request reading attributes for the same file used the same temporary path, so concurrent requests would clobber and delete each other's copy. It also left an empty directory tree behind on every call.This PR fixes it by copying to a unique filename per call, and by deleting through the disk (which doesn't throw) rather than the mount manager.
This PR also fixes an issue where those temporary copies could be written into the site's asset container. Since #7887, the local disk shortcut assigned the source disk to
$cacheDisk, which is memoized for the lifetime of the request becauseAttributesis resolved through a real-time facade. Once anything had read attributes off a local disk, every later non-local read copied into that disk instead of the temporary one.Fixes #7437
Caused by #7887