function user_update_8009

Generate a UUID for all users.

Related topics

File

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

Code

function user_update_8009(&$sandbox) {
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;

    // The first user id is 0, so it needs to start with -1.
    $sandbox['last'] = -1;
    $sandbox['max'] = db_query('SELECT COUNT(uid) FROM {users} WHERE uuid IS NULL')
      ->fetchField();
  }
  $uids = db_query_range('SELECT uid FROM {users} WHERE uid > :uid AND uuid IS NULL ORDER BY uid ASC', 0, 10, array(
    ':uid' => $sandbox['last'],
  ))
    ->fetchCol();
  update_add_uuids($sandbox, 'users', 'uid', $uids);
  $sandbox['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
}