I just added a user to an almost brand new drupal 7 install. I noticed the user ID was 13. Call me superstitious, but I deleted that user. Then I created another user.

The new user had entity ID 15. I was expecting 14 (one greater than the previous entity).

So now I'm curious. What is/was entity 14? Is there any way to find it? Is there any way to know in advance what the next entity ID will be?

Comments

user module

Line 566 of the user.module in the User module folder in core shows:

<?php
     
if (empty($account->uid)) {
       
$account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField());
      }
?>

You could also query the users table and see if anything was assigned UID 14.

- Erek J

And then there was Drupal

I thought of querying the

I thought of querying the user table for id 14. Nothing there. nothing has id 14 as far as I can tell.

I now see that entity ids come from the {sequences} table. If I recall, the sequences table was a PITA in earlier Drupal versions. I thought we got rid of it. Apparently it's back.

I think something ran a batch job, and batch_process calls db_next_id(), which bumps the id. I'm pretty sure I don't like the idea that each batch job will bump the id of the next entity.

I'm also pretty sure I don't like that there's no way to say "tell me what entity #NNN is". I mean in a way they're just numbers, but still I'd feel more confident in the system if it is kept a little tidy.

asked about it in issue queue

As I said in my other comment, I think the ID went to a batch job.

I've submitted an issue, just hoping to get some sort of official response about this. #1785042: Should each batch job get an entity ID?