Skip to content

[6.x] Prevent replacing an asset with itself - #15947

Merged
duncanmcclean merged 6 commits into
statamic:6.xfrom
edalzell:fix/replace-asset-with-itself
Nov 17, 2026
Merged

duncanmcclean merged 6 commits into
statamic:6.xfrom
edalzell:fix/replace-asset-with-itself

Conversation

@edalzell

Copy link
Copy Markdown
Contributor

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

@edalzell
edalzell marked this pull request as ready for review November 17, 2026 00:12
@duncanmcclean
duncanmcclean enabled auto-merge (squash) November 17, 2026 09:34
@duncanmcclean
duncanmcclean merged commit d715624 into statamic:6.x Nov 17, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asset removed if you replace with same file and "Delete Original" is on, which is the default

3 participants