Summary
Need to prevent the creation of entity types named with certain words (see #23). These words can be related to core and other existing entities entities, existing table names in general, protected database table names, and possibly other factors. With potential conflicts coming from so many different sources, namespacing (as suggested in #2, #4, and #19) is going to be the only sustainable solution.
This is currently the only blocker for a 7.x-2.0 release.
Looking to implement a configurable namespacing prefix, similar to how "field_" prefixes field machine names but can be configured globally.
Will need to test to make sure that existing entity types are not affected by this change - thinking about entity CRUD functions and templates/theming.
Original issue reported by @webmasterslava
I have created new entity type with machine name "category" through ECK UI, then created first entity with this entity type through ECK UI, after that I see the following error on entities overview page "admin/structure/eck/category/category":
Warning: Missing argument 2 for user_category_load() in user_category_load() (line 1914 of modules/user/user.module).
Warning: Missing argument 3 for user_category_load() in user_category_load() (line 1914 of modules/user/user.module).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of includes/entity.inc).
Recoverable fatal error. Object of class EckEntity could not be converted to string in DatabaseStatementBase->execute() (line 2135 of includes/database/database.inc).
The same error I see when I'm trying to edit or delete this entity or delete entity type. So I can delete it only manually in database at "eck_category" table.
Comment | File | Size | Author |
---|---|---|---|
#25 | Screen Shot 2020-04-28 at 10.35.29 AM.png | 82.59 KB | BassPlaya |
#25 | Screen Shot 2020-04-28 at 11.00.42 AM.png | 82.13 KB | BassPlaya |
Comments
Comment #1
fmizzell CreditAttribution: fmizzell commentedWow, I found this very amusing, so I had to go dig in to see what is going on, and I found the culprit code:
This is called in the Entity API's attachLoad method of the entity.controller class. So, there really isn't anything that ECK or Entity API can do, unless the whole community decides to change this naming convention for the entities hooks, it is just unfortunate that the user module happens to have a function called user_category_load().
Comment #2
acrazyanimal CreditAttribution: acrazyanimal commentedHa! I had a similar problem when I created an entity type called user_profile .... you can see how this could possibly go wrong. I don't think there is a way to check for this kind of thing, but perhaps by default we could add a prefix to machine names. Also I've added this note on Entity naming conventions to the documentation for ECK. Hopefully this can help others avoid this issue in the future.
Comment #3
Chris Gillis CreditAttribution: Chris Gillis commentedI just had a similar error when creating an entity named "role".
Recoverable fatal error: Object of class Entity could not be converted to string in DatabaseStatementBase->execute() (line 2139 of /Applications/MAMP/htdocs/test/includes/database/database.inc).
Is there a way to add the word "role" to a list of banned names and then display a more human-friendly error? It seems like this should not be too hard so I'm reopening this ticket.
Comment #4
acrazyanimal CreditAttribution: acrazyanimal commentedThat is a good question Chris, but the problem with that would be that any such banned list would constantly have to be updated and all conflicts would need to be found. I think it would be much simpler if we just automatically added the prefix 'eck_' to all entity machine names. This would pretty much avoid most if not all of these conflicts.
Comment #5
zacho CreditAttribution: zacho commentedI recently created an entity type called "item" and upon adding one or trying to view the entity list:
Recoverable fatal error: Object of class Entity could not be converted to string in DatabaseStatementBase->execute() (line 2139 of /home/user/public_html/d7/includes/database/database.inc).
[Delete Dumb Question here]
Comment #6
gwynnebaer CreditAttribution: gwynnebaer commentedSeems either modules would need to stop using the "_load" since it's now part of entity (certainly for D8), Entity API needs to rename. The code below, packaged into a validation on the entity name, will prevent a collision from being created, but only for one that already exists. It cannot handle the case of a module being added later that has the same name, so it's really not a true fix.
I vote for changing Entity API; hard but the right thing to do.
Comment #7
mihai_brb CreditAttribution: mihai_brb commentedI think it's the same for naming your entity "type".
Comment #8
DamienMcKennaThe module should be able to identify names that will cause conflicts.
Comment #9
tregismoreira CreditAttribution: tregismoreira commentedSame here. I've created an entity called Block (machine name "block"). So, when I tried to display the entity or delete it, I've got the same error.
Comment #10
johnlaine CreditAttribution: johnlaine commentedI think that I am having the same issue with the name "task". Everything seems to work fine until I try to delete an entity, then I get an error
Comment #11
fmizzell CreditAttribution: fmizzell commentedThe problematic entity type name "region" was reported over there #2085187: Entity name conflicts with Drupal Hook names which breaks the site
Comment #12
corentin.crouvisier CreditAttribution: corentin.crouvisier commentedI created an eck entity in relation with a node ( 2 entity references synchronized bidirectionally with my own code).
I added after a relation with the cer module and I have now the same error:
Recoverable fatal error: Object of class Entity could not be converted to string in DatabaseStatementBase->execute() (line 2171 of /includes/database/database.inc).
Disable my cer sync solve the problem, but I have a doubt about the compatibility of the two modules (or 3 modules if entity reference is a part of the problem when synchronizing entity references from eck via cer).
Note: problem only appears on eck entity creation, not editing.
Comment #13
Chris Gillis CreditAttribution: Chris Gillis commentedcorentin.crouvisier - I would suggest creating a separate ticket for that. If you think it is related to this issue, you can link to it, and let us know what your eck entity is named.
Comment #14
corentin.crouvisier CreditAttribution: corentin.crouvisier commentedYou are right, it's not an issue relative to the entity name, I move it to this cer issue cer+eck+entity reference fields : fatal error creating entity contents, but I think the fatal error caused by an entity object sended as argument could have a similar explaination with #10 and could be associated.
Comment #15
pianomansam CreditAttribution: pianomansam commentedI'm going to update the title of this issue to focus it just on entity type names. I'll create separate issues for reserved properties, bundles, and fields if they don't already exist.
Comment #16
pianomansam CreditAttribution: pianomansam commentedI found two more reserved entity type names: button and link.
Comment #17
marco.b CreditAttribution: marco.b as a volunteer commentedI ran into this issue by creating eck bundle 'item' before I read that (#5) and earned the error:
Set Priority to Major because after that I couldn't delete the bundle anymore at sidebuilder level. Even uninstalling ECK isn't possible through backend.
I suggest ECK should have something like a namespace blacklist.
Comment #18
marco.b CreditAttribution: marco.b as a volunteer commentedChanged this one to bug report, for reasons see #17.
Comment #19
C-LogemannAs a Module to provide entity configurations for site builders this is really a bug in code. And if there can be situations where you can't revert a "bad" entity name it's a critical issue in my opinion.
I think a blacklist as suggested in #17 by would be easy to realize. But what about a default namespace prefix "eck_" to avoid any conflicts with other modules?
Comment #20
marco.b CreditAttribution: marco.b as a volunteer commentedsame with eck bundle 'role' (that was predictable).
Comment #21
akalata CreditAttribution: akalata commentedI usually namespace, this time I didn't. Type name "group" MySQL/MariaDB really doesn't like that....
I think we do need to make an effort to protect against these errors, since there is no way to recover (on D8, I can't uninstall just using drush).
Comment #22
kpv CreditAttribution: kpv commentedsame for drupal 8
entity type with machine name
'config'
breaks entities overview page and makes ECK mostly unusableComment #23
akalata CreditAttribution: akalata commentedSo far reported in this issue:
Updating issue summary with the goal for namespacing; if there are users that don't like the forced namespacing, they can still create their entities programatically.
Though I guess we don't need to force a specific namespace; it can default to "eck_" but could otherwise be a text string, similar to the the way "field_" can be configured.
Comment #24
Kristen PolDowngrading to Normal since this issue is 7 years old and users are using ECK ok. Documentation (to not use existing names) can help with this right now.
Comment #25
BassPlaya CreditAttribution: BassPlaya as a volunteer commentedI believe I had a similar issue when using the machine name "transaction" when using Drupal Commerce module.
I had a very similar experience like mentioned above:
My solution was to create a quick module to debug i.e. print all entities on the site and then do a search for which entity you seem to have a problem with. What I found was "transaction_id" used by Drupal Commerce and I believe that's the reason for the error.
I got the idea from this link: How can I find all Entity Types in a site.
put that in a simple module, enable it and find the culprit.
See screenshots.