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.

Comments

diqidoq created an issue. See original summary.

dqd’s picture

Title: Change order of requests and calls to prevent WSOD when creating entity bundly ID with too much characters » Change order of requests and calls to prevent WSOD when creating machine name ID with too much characters
Issue summary: View changes
dqd’s picture

Issue summary: View changes
dqd’s picture

Issue summary: View changes
dqd’s picture

For 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.

dqd’s picture

Title: Change order of requests and calls to prevent WSOD when creating machine name ID with too much characters » WSOD by creating types: Limit of 32 chars exceeded when creating machine name ID with too much characters
dqd’s picture

Issue summary: View changes
dqd’s picture

Issue summary: View changes
legolasbo’s picture

Status: Active » Needs review
StatusFileSize
new1.48 KB

Attached patch contains a test that exposes this issue.

Status: Needs review » Needs work

The last submitted patch, 9: 2975136-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

legolasbo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.48 KB
new2.73 KB

While 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.

legolasbo’s picture

StatusFileSize
new3.48 KB
new1.6 KB

And this patch should fix the issue.

rshafakian’s picture

Status: Needs review » Reviewed & tested by the community

Reproduced 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!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 2975136-12.patch, failed testing. View results

legolasbo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.46 KB

Rerolled the patch.

laravz’s picture

The patch in #15 differs from the patch in #12 by a class rename only. I only have the following remark:

+++ b/src/Entity/EckEntityType.php
@@ -75,6 +75,20 @@ class EckEntityType extends ConfigEntityBase implements EckEntityTypeInterface {
+    if (strlen($this->id()) > 27) {

It might be a bit cleaner to set the number (27) as a constant, instead of hard coding it into separate files.

rshafakian’s picture

StatusFileSize
new3.69 KB
new1.7 KB

This patch includes the suggestion from #16 to add the max length to a variable instead of hard coding it.

  • legolasbo committed 567ae21 on 8.x-1.x
    Issue #2975136 by legolasbo, rshafakian, diqidoq, LaravZ: WSOD by...
legolasbo’s picture

Status: Needs review » Fixed

Committed and pushed to 8.x-1.x. Thanks for your help everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.