diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-11-22 21:02:15 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-11-22 21:02:15 +0000 |
commit | 59312988a1119448fa007f4645779601e6804915 (patch) | |
tree | 4298a96c35744dfe266a0f99368c76d75896784e /modules/system | |
parent | aef264dfb64de218a84f5ecff32d6423a53f02eb (diff) | |
download | brdo-59312988a1119448fa007f4645779601e6804915.tar.gz brdo-59312988a1119448fa007f4645779601e6804915.tar.bz2 |
#194367 by chx: better targetted user id setting, so auto increment issues will not cause problems with wiped databases
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.install | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 1a7866824..43650b93d 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -305,9 +305,11 @@ function system_install() { // anyways. So we insert the superuser here, the uid is 2 here for now, but // very soon it will be changed to 1. db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); - // This sets the above two users to 1 -1 = 0 (anonymous) and - // 2- 1 = 1 (superuser). We skip uid 2 but that's not a big problem. - db_query('UPDATE {users} SET uid = uid - 1'); + // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 + // otherwise MySQL might insert the next auto_increment value. + db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); + // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. + db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user'); db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); |