diff options
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/user.install | 3 | ||||
-rw-r--r-- | modules/user/user.module | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/modules/user/user.install b/modules/user/user.install index 610d3d566..2b93e4e68 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -102,10 +102,11 @@ function user_schema() { 'description' => 'Stores user data.', 'fields' => array( 'uid' => array( - 'type' => 'serial', + 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: Unique user ID.', + 'default' => 0, ), 'name' => array( 'type' => 'varchar', diff --git a/modules/user/user.module b/modules/user/user.module index fe75f1c7b..48140a862 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -448,6 +448,11 @@ function user_save($account, $edit = array(), $category = 'account') { user_module_invoke('update', $edit, $user, $category); } else { + // Allow 'uid' to be set by the caller. There is no danger of writing an + // existing user as drupal_write_record will do an INSERT. + if (empty($edit['uid'])) { + $edit['uid'] = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField()); + } // Allow 'created' to be set by the caller. if (!isset($edit['created'])) { $edit['created'] = REQUEST_TIME; |