0

I was doing some work on my custom module which hooks into and modifies Drupal Commerce, and all of a sudden the checkout page wont load and I get this error:

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of /var/www/test.dev/htdocs/includes/entity.inc).
EntityMalformedException: Missing bundle property on entity of type commerce_customer_profile. in entity_extract_ids() (line 7693 of /var/www/test.dev/htdocs/includes/common.inc).

and I have no idea how to fix it! I commented out what I had changed and nothing worked. I even did a git stash on all of my work to revert the changes and still nothing. My only guess is that somehow the database got messed up. How can I fix this? If I have to mess with the database, where do I start?

2

When you declare an entity and function entity_get_info($entity_type = NULL) is called, the next function cache_set("entity_info:$langcode", $entity_info) is also called which stores the entity info in the cache table, so probably your change is cached in the database.

If you're executing drush cc all and you have the same message error again, you can try several more things:

  • You can call this function entity_info_cache_clear() https://api.drupal.org/api/drupal/includes!common.inc/function/entity_info_cache_clear/7.

  • Try executing SELECT cid FROM cache WHERE cid LIKE 'entity_info%' from MySQL command line and then DELETE FROM cache WHERE cid="entity_info:en" -> "en" or whatever depending or your language config.

  • Try truncating the cache tables:

    You can do:

    drush sqlc with

    SHOW TABLES LIKE 'cache_%';

    TRUNCATE cache_tablename;

    in order to remove the cached data where entity info is stored. The content of this tables are regenerated programatically when you make a request.

That probably should works

| improve this answer | |
  • what does that do? Do I need to back up my database before I do that command? and is tablename supposed to be replaced with a real tablename, if so, what? – user1015214 Nov 19 '13 at 15:51
  • you can run drush cc all to clear all the caches but it is probably going to show you the same error message, so you can clear the caches manually. with drush sqlc you are coneccting to the database, is just like mysql -uuser -ppass. Once conected you can executed show tables like '%cache%' to find out which tables in your database have a name with that pattern and finally you can remove the content of this tables executing truncate nameoftable. I suggest you to truncate all the tables named cache_whatever becouse I am not sure now in which one exactly is storaged the entity info – Enxebre Nov 19 '13 at 15:56
  • i've never done something like that before. Should I backup my database first? – user1015214 Nov 19 '13 at 16:18
  • It says here not to flush the form cache drupal.stackexchange.com/questions/24945/… – user1015214 Nov 19 '13 at 16:20
  • Yeah, you dont need to clear that cache, What it says is just after clear cache the form will has lost the current info so if would be necessary reload the page before it can work. When you declare an entity entity_get_info($entity_type = NULL) is called an this is also called cache_set("entity_info:$langcode", $entity_info); it storage the entity info in the cache table, that is probably which is causing your break, and that is what you need to remove in order to be stored again by Drupal with the right info – Enxebre Nov 19 '13 at 16:30
0

I figured out the issue. I debugged in the common.inc file and I was able to determine that there was an issue with the User entity. I looked back into my code and saw that I had written

global $user;
twice inside of one hook. I took this out and the page loaded again

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.