Content entities with non-numeric IDs cause exceptions when deleted

Created on 30 July 2024, 5 months ago
Updated 1 August 2024, 5 months ago

Problem/Motivation

Encountered when running Linkchecker in the same Drupal instance as Entityqueue. Caused by deleting an Entity Subqueue entity, which is a content entity but uses an alphanumeric entity ID. Sample exception below:

ERROR: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'events_featured_homepage': DELETE FROM "linkchecker_index"  WHERE ("entity_id" = :db_condition_placeholder_0) AND ("entity_type" = :db_condition_placeholder_1); Array (     [:db_condition_placeholder_0] => events_featured_homepage     [:db_condition_placeholder_1] => entity_subqueue )  in Drupal\linkchecker\LinkCleanUp->cleanUpForEntity() (line 148 of /data/app/modules/contrib/linkchecker/src/LinkCleanUp.php)

In SqlContentEntityStorage.php line 763:
                                                                                                    
  SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'events_feature  
  d_homepage': DELETE FROM "linkchecker_index"                                                      
  WHERE ("entity_id" = :db_condition_placeholder_0) AND ("entity_type" = :db_condition_placeholder  
  _1); Array                                                                                        
  (                                                                                                 
      [:db_condition_placeholder_0] => events_featured_homepage                                     
      [:db_condition_placeholder_1] => entity_subqueue                                              
  )                                                                                                 
                                                                                                    

In ExceptionHandler.php line 56:
                                                                                                    
  SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'events_feature  
  d_homepage': DELETE FROM "linkchecker_index"                                                      
  WHERE ("entity_id" = :db_condition_placeholder_0) AND ("entity_type" = :db_condition_placeholder  
  _1); Array                                                                                        
  (                                                                                                 
      [:db_condition_placeholder_0] => events_featured_homepage                                     
      [:db_condition_placeholder_1] => entity_subqueue                                              
  )                                                                                                 
                                                                                                    

In StatementWrapperIterator.php line 111:
                                                                                                    
  SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'events_feature  
  d_homepage'                                                                                       

Steps to reproduce

  1. Install both Linkchecker and Entityqueue
  2. Create an Entity Queue config entity
  3. Add an Entity Subqueue content entity linking to the Entity Queue we created
  4. Delete the Entity Subqueue we just created

Proposed resolution

It'd be quickest and easiest to ignore entities with non-numeric IDs, and I can probably do up a patch for this pretty quick, but it's probably not the ideal long-term solution.

Remaining tasks

  • Implement short-term patch for anyone who needs it
  • Determine potential approaches
  • Figure out a solution
  • Implement long-term solution

User interface changes

None.

API changes

None.

Data model changes

None (yet). A long term solution may involve storing the entity ID as a string instead of an int.

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇦🇺Australia geoffreyr

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

Comments & Activities

Production build 0.71.5 2024