Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x]: Moving Sites to other site groups moves assets to new subfolder when using dynamic upload location #16004

Open
mnlmaier opened this issue Nov 4, 2024 · 1 comment

Comments

@mnlmaier
Copy link

mnlmaier commented Nov 4, 2024

What happened?

Description

Hi, first of all, I am not quite sure if this is a bug at all, but for us, it's definitely unintended behavior and there seem multiple ways to resolve this, I'm wondering which one's "right".

Our situation is as follows:

  • Asset Field (let's call it postImage) was created with its default location defined by {site.group}
  • When uploading an asset, the asset gets stored in /siteGroup1/asset.ext as expected
  • When moving site1 from siteGroup1 to siteGroup2, all assets get moved to a new subfolder accordingly and will now be referenced using /siteGroup2/asset.ext
  • Reason we are moving sites was to simplify our site group structure, so basically all sites are affected by this change

Though it kind of makes sense why this is happening, I'm wondering if its intended or not. We're talking thousands of assets here wich we now need to revert (which shouldn't pose a problem, since we could — in theory — just roll back the site group structure, right)?

While we have a backup, we'd love to "get it right" without actually using it. The final goal would be to:

  • Switch the dynamic path to the Site Name instead of Group Name
  • Using a queue job, trigger to move them to the new path with the siteName instead of groupName

What's the best way to achieve this? Update all asset fields' dynamic paths and then run a queue job, which one would it be?

Steps to reproduce

See above

Expected behavior

Assets stay where they are

Actual behavior

Assets get moved around (could also be intended)

Craft CMS version

Craft Pro 3.9.5

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@brandonkelly
Copy link
Member

Is your Assets field’s “Restrict assets to a single location” setting enabled? If so, this is expected behavior, yes.

If you disable that setting, the existing assets should stay put once they’ve been uploaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants