-
Notifications
You must be signed in to change notification settings - Fork 684
Closed
Labels
Description
What happened?
Description
I've used \craft\services\Elements::mergeElements() but it doesn't seem to update relations properly. My outgoing asset was related to an entry (directly) and after merging, the persisting asset didn't take it's place.
I did a bit of digging and it seems that although it does update rows in the relations table, it doesn't update the content column in the elements_sites table.
It does add a FindAndReplace queue job, but this only updates reference tags.
After merging it still contains the old asset's id:
Steps to reproduce
- Create an entry type with an asset field
- Add 2 assets
- Save an entry with the asset field set to one of the assets
- Use \craft\services\Elements::mergeElements() to merge the 2 assets - eg. in a console action
Expected behavior
The entry should now show the second asset in the CMS
Actual behavior
Asset field appears empty
Craft CMS version
Craft Pro 5.8.16
PHP version
8.3.21
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Safe mode
{ // ... "c4e361f2-86cb-4a0d-9c11-1d948f487605": [ 135876 ], // ... }