WSOD on entity bundle admin paths and Drupal database update path with error
Drupal\Core\Entity\Exception\EntityTypeIdLengthException: Attempt to create an entity type with an ID longer than 32 characters: reusable_entityreference_bundle_type. in Drupal\Core\Entity\EntityType->__construct() (line 299 of core/lib/Drupal/Core/Entity/EntityType.php)
is caused by user input while creating a new entity bundle with too much characters for the machine name ID.
Drupal core API declares a maximum of 32 characters for machine name IDs but it cannot prevent a bundle of calls and requests which hook into Core API to do things half the way before this limitation prevents the group of calls and requests to go any further. The database table config row is already written and will break the whole site.
I started discussing the idea how we can make Core API more rock solid in this manner to prevent this, but this is not an easy task and possibly an impossible one, since the Core API can not know what the ID creation is part of, until we invent a certain group logic which checks against all parts of the group of events first.
Until then we have to fix this on module level IMMEDIATELY otherwise ECK runs in a bunch of user reports before it even has reached second beta.
So we need to change the order of requests and calls grouped by the user input for entity bundle or entity creation to prevent WSOD when the step creating entity bundle ID with too much characters occurs, otherwise we get this error on a state when ECK already did "things", before the process gets interrupted by this character limitation and the Drupal project database is broken and we can only repair it manually.
And we need a machine name input autolimit and check in the very first step of course, to assist the users input, who do not realize that machine name gets created automatically by giving bundles or entities a name. And to start with a fast fix we should add a warning on entity bundle creation page and entity creation page that the user should check the length of the machine name first before hitting enter (early work-around).
The error occurs on both: dev and latest beta.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | interdiff-15-17.txt | 1.7 KB | rshafakian |
| #17 | 2975136-17.patch | 3.69 KB | rshafakian |
| #15 | 2975136-15.patch | 3.46 KB | legolasbo |
| #12 | interdiff-11-12.txt | 1.6 KB | legolasbo |
| #12 | 2975136-12.patch | 3.48 KB | legolasbo |
Comments
Comment #2
dqdComment #3
dqdComment #4
dqdComment #5
dqdFor those running into this WSOD: manually delete the config row(s) in the database table "config" regarding the eck entity or bundle you tried to create. The row(s) start with eck.xxx. and end with the name you tried to use. It removes at least the WSOD. But since this is a manual editing of the database I strongly recommend to remove/uninstall ECK completely and reinstall it if required since I don't know if there is some data dependency between these config database table rows and other eck database entries which are now lost ends making trouble later. ! This is only a fast quick and dirty fix to get on. We need work on this of course.
Comment #6
dqdComment #7
dqdComment #8
dqdComment #9
legolasboAttached patch contains a test that exposes this issue.
Comment #11
legolasboWhile debugging this I noticed that limiting the entity type machine name length to 32 doesn't solve the issue. This is because the bundle entity type machine name is actually 5 characters longer than the entity machine name. I've therefore adjusted the test accordingly.
Comment #12
legolasboAnd this patch should fix the issue.
Comment #13
rshafakian commentedReproduced error on a clean install. Then applied patch to a fresh install of drupal and eck. Character limit is now set to where it should be. Great work!
Comment #15
legolasboRerolled the patch.
Comment #16
laravz commentedThe patch in #15 differs from the patch in #12 by a class rename only. I only have the following remark:
It might be a bit cleaner to set the number (27) as a constant, instead of hard coding it into separate files.
Comment #17
rshafakian commentedThis patch includes the suggestion from #16 to add the max length to a variable instead of hard coding it.
Comment #19
legolasboCommitted and pushed to 8.x-1.x. Thanks for your help everyone.