[6.x] Add Asset::moveUnique() method#14236
Open
lwekuiper wants to merge 2 commits intostatamic:6.xfrom
Open
Conversation
Add $unique parameter to move() for parity with rename(). When true, ensureUniqueFilename() generates a collision-free name in the target folder. Simplify rename() to delegate uniqueness logic to move().
jasonvarga
requested changes
Mar 12, 2026
Member
jasonvarga
left a comment
There was a problem hiding this comment.
Adding a new argument is a breaking change.
Either target master so this will be in v7 (but there is no planned release for a while).
Or, make this change in a non-breaking way. Maybe you could create a moveUnique method that checks uniqueness then calls move. It could be marked as deprecated with the intention of making the breaking change in v7.
…r on move() Replace the breaking $unique parameter on move() with a dedicated moveUnique() method. Update rename() to delegate to moveUnique() when unique filenames are needed.
Contributor
Author
|
Thanks for the feedback! I've updated the PR to use a dedicated |
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.
Asset::rename($filename, $unique = false)supports automatic unique filename generation viaensureUniqueFilename(), but there is no equivalent forAsset::move(). When moving an asset to a folder where a filename collision exists, developers must implement their own uniqueness logic.This PR adds a dedicated
moveUnique()method as a non-breaking addition, and updatesrename()to delegate to it when$unique = true.Changes
Asset::moveUnique($folder, $filename)— new method that callsensureUniqueFilename()before delegating tomove().Asset::rename()— updated to delegate tomoveUnique()when$unique = true, instead of handling uniqueness directly.Asset::move()— signature unchanged, no breaking change.