It's a well-known problem that you can't use the node:nid token in a node's automatic title (#176468: The token "[nid]" doesn't work.), and more generally, anything that you want to do with an entity that you might want to do to a brand new entity and which needs the ID, won't work.
So here's my idea. What if we 'pre-booked' the ID, by entering a mostly empty row in the entity's table before all the save hooks are fired?
Here's pseudocode to illustrate this:
function entity_save($entity) {
// Pre-book a row.
$new_row = drupal_write_record(entity table, array());
$entity->id = $new_row->id;
// Fire the rest of the normal save procedure and fire the usual hooks.
}
We'd presumably need a different way of knowing it's a new entity rather than an update as most hooks will use the presence / absence of the id key. But apart from that, could this work?
Comments
Comment #13
smustgrave CreditAttribution: smustgrave at Mobomo commentedWonder if this would still be a wanted for D10?