Hi,
Got a situation where I wish to update a bunch of Scald Image atoms, eg. we need to programmatically update the images for all the Scald Images on the system.
What I have done now is I fetched all the Scald Image entities with EntityFieldQuery and after that used scald_atom_load to load the objects. Then I updated the base_entity image url and filename + thumbnail url into a new one (an existing image and its path) and tried to use scald_atom_save on it.
For some reason, the atoms do not get updated but not receiving any error message either. Question is, is the scald_atom_save the correct function to use for updating an existing atom?
Comments
Comment #1
jcisio CreditAttribution: jcisio commentedI've just tested and don't have any problem. You even don't have to update the base_id because it will be synchronized with field_thumbnail.
My test that works (tested with the latest git):
Comment #2
gifad CreditAttribution: gifad commentedFor this simple task, I'd go directly to db_update the base_id field of scald_atoms table;
Am I wrong ?
(Besides caching issues...)
Comment #3
gifad CreditAttribution: gifad commentedYes, I was wrong, I forgot to manage the file_usage table;
Note that the snippet provided by jcisio works (no surprise), but, if the "old" file was not used by another module, it is deleted immediately, from file_managed table, and from disk !
This may be the desired effect, or not...
Comment #4
jcisio CreditAttribution: jcisio commentedIf you want to manipulate the database directly, you need to modify at the same time: 1/ the scald_atoms table for base_id, 2/ the field_thumbnail table 3/ the file_usage table.
And yes, the fact the unused files are deleted is a desired effect. At least, it is not a bug. More detail here #1399846: Make unused file 'cleanup' configurable.
Also, I think that this issue is fixed.
Comment #5
gifad CreditAttribution: gifad commentedThanks, jcisio, for the infos