function system_update_8024

Generate a UUID for all files.

Related topics

File

drupal/core/modules/system/system.install, line 1655
Install, update and uninstall functions for the system module.

Code

function system_update_8024(&$sandbox) {
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;
    $sandbox['last'] = 0;
    $sandbox['max'] = db_query('SELECT COUNT(fid) FROM {file_managed} WHERE uuid IS NULL')
      ->fetchField();
  }
  $fids = db_query_range('SELECT fid FROM {file_managed} WHERE fid > :fid AND uuid IS NULL ORDER BY fid ASC', 0, 10, array(
    ':fid' => $sandbox['last'],
  ))
    ->fetchCol();
  update_add_uuids($sandbox, 'file_managed', 'fid', $fids);
  $sandbox['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
}