Skip to content

[6.x] Add $unique parameter to Asset::move()#14236

Open
lwekuiper wants to merge 1 commit intostatamic:6.xfrom
lwekuiper:feat/asset-move-unique
Open

[6.x] Add $unique parameter to Asset::move()#14236
lwekuiper wants to merge 1 commit intostatamic:6.xfrom
lwekuiper:feat/asset-move-unique

Conversation

@lwekuiper
Copy link
Contributor

@lwekuiper lwekuiper commented Mar 12, 2026

Asset::rename($filename, $unique = false) supports automatic unique filename generation via ensureUniqueFilename(), but Asset::move($folder, $filename) does not. When moving an asset to a folder where a filename collision exists, developers must implement their own uniqueness logic.

This PR adds the same $unique parameter to move() for parity with rename(), and simplifies rename() to delegate its uniqueness logic to move().

Changes

  • Asset::move($folder, $filename, $unique) — new optional $unique parameter. When true, calls ensureUniqueFilename() before building the new path.
  • Asset::rename() — simplified to delegate uniqueness to move() instead of handling it directly.
  • Asset::moveQuietly() — no changes needed, already uses func_get_args().
  • Tests — three new test cases covering move with unique flag (conflict, no conflict, and default behavior).

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().
Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

2 participants