Repository navigation
[6.x] Prevent replacing an asset with itself - #15947
Merged
duncanmcclean merged 6 commits intoNov 17, 2026
Merged
Conversation
edalzell
marked this pull request as ready for review
November 17, 2026 00:12
Co-authored-by: Duncan McClean <duncan@duncanmcclean.com> Amp-Thread-ID: https://ampcode.com/threads/T-445d2ec3-2267-4432-869f-36d3dfbf8d2a
Amp-Thread-ID: https://ampcode.com/threads/T-445d2ec3-2267-4432-869f-36d3dfbf8d2a Co-authored-by: Duncan McClean <duncan@duncanmcclean.com>
duncanmcclean
enabled auto-merge (squash)
November 17, 2026 09:34
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.
Replacing an asset with itself deletes it when "Delete Original Asset" is on (the default). Every way into this ends with the original asset chosen as its own replacement: uploading the same filename and choosing "Overwrite Existing File", choosing "Discard and use existing", or just picking it in the browser.
Asset::replace()then deletes the original, which is the same file.Following Jason's suggestion on #11230, the Replace dialog now validates that the new asset isn't the one being replaced, and points to Reupload instead. The assets fieldtype's
fieldRules()assumed every rule was a string and crashed on rule objects/closures, so it now passes those through.Closes #11229