Insert Error when entity_extract_ids returns NULL, length of entity_type is greater than 32 characters or entity_id is not an integer value.

Created on 16 December 2014, almost 10 years ago
Updated 2 June 2023, over 1 year ago

I am having a problem with the code in the cases when the entity_extract_ids() returns a null value - which is apparently quite possible in the Entity world? (Code line 7722 in drupal7.32/includes/common.inc says "// Objects being created might not have id/vid yet."). This causes the entity_modified_entity_update() and entity_modified_last() to have a query error.

Now, this might be a problem with the module that I am using (a custom entity with two tables that share a PKey serial field), or it might be just something that can happen (as noted in includes/common.inc). For what it's worth I include a patch here to test for a valid integer before trying to query.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States robertwb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada hadsie

    I'm running into a similar problem but when trying to work with MySQL 8 which has added strict type checking and is throwing an exception in hook_entity_delete() in some edge cases.

    This patch addresses that by checking is_numeric on the entity_id before attempting to delete as well as the recommendation from @jedihe to restrict entity_update to numeric IDs.

Production build 0.71.5 2024