I have noticed at my Drupal 7 that there are gaps between the uid's of new users. The UID of a new user should increase by one from the highest assigned UID in database. However, I have noticed gaps of even a thousand.
Inside user.module file, there is the following code:
// 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($account->uid)) {
$account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField());
}
I have made the QB query read like this:
$account->uid = db_next_id(db_query('SELECT MAX(uid) FROM users')->fetchField());
It appears that this solves the issue. My question, is there really a mistake inside the core user.module file? Is it safe to modify the file the way I did? Thanks.
UPDATE:
The above does not make a difference after all. I have changed the line to this:
$account->uid = db_query('SELECT MAX(uid) FROM users')->fetchField() + 1;
This works with no reference to db_next_id. For me it is very important to increase the uid's always by one and this is one way to do it.