How to resolve Catchable fatal error in entity.inc? Locally (WAMP) I have created a new GIT branch to install Drupal Commerce on my site. Everything went well and I have begun configuring my new shop. But when I decided to pull this branch into my remote test site, I get this error:


  Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be of the type array, null given, called in /home/httpd/mysite/test.mysite.se/includes/entity.inc on line 317 and defined in /home/httpd/mysite/test.mysite.se/includes/database/select.inc on line 1316


Since I can't reach my admin pages (white screen with error message) and Drush stopped working as well, I used MySQL from the command line to import the database on the remote test site. So now both the codebase and the database should be the same on the remote test site as I have locally. Instead I get the above error. Any ideas? I have a feeling that Rules is involved in this, but that's just a feeling.

I have now done everything from the beginning, with the same result. I have installed all the commerce modules and their dependencies (Entity api, Rules, Address field etcetera) in the suggested order. Everything works fine until I export a database dump and add &amp; commit all changes to my new git branch. After pulling that branch and importing the database dump in my test site (or even locally), I get the message above. 

I have managed to run cron, which gave me this message:


  User warning: Missing database columns for the exportable entity
  rules_config as defined by entity_exportable_schema_fields(). Update
  the according module and run update.php! i _entity_defaults_rebuild()
  (rad 872 av C:\wamp\www\sites\all\modules\entity\entity.module).


... allthough I am using the latest version of Rules and when I run the database update, the message is that there is no update pending.

I have also seen this warning:


  Warning: array_flip() expects parameter 1 to be array, null given i
  DrupalDefaultEntityController->buildQuery() (rad 308 av
  C:\wamp\www\includes\entity.inc).


Any hints on what I can do to get my site back on track?
In case anyone else has a similar problem, here is how I solved it. I began by using Drush to disable the commerce modules one after another (in the correct order) to detect which module caused the error. I got so far that in the end I had disabled all the commerce modules, plus Rules and Entity token. And still the same error message was showing (the first one in my question). 

I suspected that I really needed to flush all cache, but I could not reach any page in the site, and still it was not enough to truncate all the cache tables in the db and to run Drush cc all. So what to do? I finally found a way to flush all caches with this snippet (https://www.drupal.org/docs/7/administering-drupal-7-site/clearing-or-rebuilding-drupals-cache) in a file named for example clear.php in the web root:

&lt;?php
// Define static var.
define('DRUPAL_ROOT', getcwd());
// Include bootstrap.
include_once('./includes/bootstrap.inc');
// Initialize stuff.
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Clear cache.
drupal_flush_all_caches();


After saving the above file in the web root, you can just navigate to it whith the browser. In my case I also had to comment out all the memcached rows in settings.php in order for this to work (I got a "Cannot redeclare ..." error message).

When I finally managed to flush all caches this way, the site began to work. I still don't know how I would have done this otherwise. And "Flush all caches" obviously does somehting more than what is accomplished by executing drush cc all + manually truncating all the cache tables in the database.

So if anyone else has a similar problem with white screens and error messages, first try to flush all caches with the method above. And if you use memcached, you will have to comment out everything that regards memchached in settings.php in order to do this.