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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dermario created an issue. See original summary.

dermario’s picture

Issue summary: View changes
dermario’s picture

Status: Active » Needs review
megadesk3000’s picture

I confirm that patch #3 works for me.

dermario’s picture

Assigned: dermario » Unassigned
vinmassaro’s picture

Ran 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.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

To go in asap

vinmassaro’s picture

@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

joseph.olstad’s picture

Would consider that in a new issue, unless you have something ready today

vinmassaro’s picture

I 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.

joseph.olstad’s picture

Version: 7.x-2.0-beta2 » 7.x-2.x-dev

sorry still haven't put this in yet. been busy.

joseph.olstad’s picture

I just triggered more tests. Just to be safe testing all available versions of php

  • joseph.olstad committed a59c778 on 7.x-3.x authored by dermario
    Issue #2650842 by dermario: file_entity_update_7212() calculates a wrong...

  • joseph.olstad committed 2e39332 on 7.x-2.x authored by dermario
    Issue #2650842 by dermario: file_entity_update_7212() calculates a wrong...
joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.