Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am facing big problems in file_entity_update_7212(). The value in $sandbox['progress'] is calculated in the wrong place, which results in an incomplete migration and a loss of data.
$values = array();
foreach ($results as $result) {
foreach (array('width', 'height') as $key) {
$values[] = array(
'fid' => $result->fid,
'name' => $key,
'value' => serialize((int) $result->{$key}),
);
}
$sandbox['progress'] += count($results);
$sandbox['current_fid'] = $result->fid;
}
By doing so, the amount of result items is added for each item again. In that case we fetch 20 items from db, which sets progress to 400 instead of 20. If the update_hook is run a second time the start is 400 and not 20! Moving the line $sandbox['progress'] += count($results); below the loop should solve the problem.
Comments
Comment #2
dermarioComment #3
dermarioComment #4
dermarioComment #5
megadesk3000 CreditAttribution: megadesk3000 commentedI confirm that patch #3 works for me.
Comment #6
dermarioComment #7
vinmassaro CreditAttribution: vinmassaro commentedRan into this and did not realize it. Is it possible to fix the file_metadata table after the fact? The image_dimensions table is now gone and only a portion of the records were written to file_metadata. Thanks.
Comment #8
joseph.olstadTo go in asap
Comment #9
vinmassaro CreditAttribution: vinmassaro commented@joseph.olstad: would you consider adding an update hook to reinsert this data for sites who failed this update and now have lost the data? Thanks
Comment #10
joseph.olstadWould consider that in a new issue, unless you have something ready today
Comment #11
vinmassaro CreditAttribution: vinmassaro commentedI don't have anything ready but might be able to create a patch. I just need help understanding how to retrieve the images managed by file_entity, and I could then write a hook to recreate the file_metadata info.
Comment #12
vinmassaro CreditAttribution: vinmassaro commentedAdding #2983855: Recreate file_metadata table due to data loss in file_entity_update_7212
Comment #13
joseph.olstadsorry still haven't put this in yet. been busy.
Comment #14
joseph.olstadI just triggered more tests. Just to be safe testing all available versions of php
Comment #17
joseph.olstad