diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-18 06:56:24 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-18 06:56:24 +0000 |
commit | 3dddaa3e6ff47b52df5836a49272952893208ddc (patch) | |
tree | 2f3f069774f2f2091a0a169c6210fc356e2d057a /modules/user | |
parent | 1650fea5d949b576bcc779d6315250da0ba7ec82 (diff) | |
download | brdo-3dddaa3e6ff47b52df5836a49272952893208ddc.tar.gz brdo-3dddaa3e6ff47b52df5836a49272952893208ddc.tar.bz2 |
#356074 by chx and Damien Tournoud: Provide a sequences API. Gets rid of stupid tables that only contain an incrementing ID, and fixes database import problems due to user ID 0.
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; |