#194367 by chx: better targetted user id setting, so auto increment issues will not cause problems with wiped databases

6.x
Gábor Hojtsy 2007-11-22 21:02:15 +00:00
parent aef264dfb6
commit 59312988a1
1 changed files with 5 additions and 3 deletions

View File

@ -305,9 +305,11 @@ function system_install() {
// anyways. So we insert the superuser here, the uid is 2 here for now, but // anyways. So we insert the superuser here, the uid is 2 here for now, but
// very soon it will be changed to 1. // 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())); 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 // This sets the above two users uid 0 (anonymous). We avoid an explicit 0
// 2- 1 = 1 (superuser). We skip uid 2 but that's not a big problem. // otherwise MySQL might insert the next auto_increment value.
db_query('UPDATE {users} SET uid = uid - 1'); 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')", 'anonymous user');
db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user');