From 59312988a1119448fa007f4645779601e6804915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Thu, 22 Nov 2007 21:02:15 +0000 Subject: [PATCH] #194367 by chx: better targetted user id setting, so auto increment issues will not cause problems with wiped databases --- modules/system/system.install | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/system/system.install b/modules/system/system.install index 1a786682469..43650b93d90 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');