I made an entity called "transaction" using the ECK UI
/admin/structure/entity-type/add

After a while I got stuck with this error at
/admin/structure/entity-type/transaction

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 179 of /public_html/includes/entity.inc).
Recoverable fatal error: Object of class Entity could not be converted to string in DatabaseStatementBase->execute() (line 2168 of /public_html/includes/database/database.inc).

Turns out the reason was at DrupalDefaultEntityController->attachLoad() where they:

call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);

I'm using Drupal Commerce and my entity was called "transaction", but that apparently clashed with Drupal Commerce, since the previous snippet translated to: commerce_payment_transaction_load, which gave the error.

Could you recommend a way of fixing this? Should I make a validator for the entity-type/add form which would check for existing entity names perhaps?

Comments

KimmoT’s picture

Status: Active » Postponed

After a bit of testing I noticed this might not be a naming issue. I have to double check what the cause is.

KimmoT’s picture

Status: Postponed » Active

At first this looked like a duplicate of:
https://drupal.org/node/1345264

But after renaming the conflicting entity and bundle I still get the error:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 218 of /sites/all/modules/entity/includes/entity.controller.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 359 of /includes/entity.inc).
Recoverable fatal error: Object of class Entity could not be converted to string in DatabaseStatementBase->execute() (line 2167 of /includes/database/database.inc).

...when trying to view, edit or delete a single entity via the entity list at
domain.com/{entity}/{bundle}/4
domain.com/{entity}/{bundle}/4/edit
domain.com/{entity}/{bundle}/4/delete

acbramley’s picture

Getting these errors on fresh install. Steps to reproduce:

1) Install drupal minimal installation
2) Download and enable latest dev version of ECK (this will install ctools and entity)
3) Create a new entity type through the ui with a bundle.
4) Create a new item of your new entity
5) Try to view this item.

acbramley’s picture

By the way my entity and bundle were:

legal_entity
rest_home

so urls were /legal_entity/rest_home/1

acbramley’s picture

Status: Active » Closed (duplicate)