function node_update_8006

Generate a UUID for all nodes.

Related topics

File

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

Code

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