array_flip():Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()

The most common cause of this error is using a something_load() function with an array as argument. This is not supported anymore because the load_multiple() functions need to be used for this now.

Example in D6:

<?php
// Using array with the id was already discouraged in D6 but still worked.
$user = user_load(array('uid' => 1));
$user = user_load(array('name' => 'admin'));
?>

Drupal 7:

<?php
// Argument to a load() function *must* be a single id
$user = user_load(1);

// Querying for another attribute is a bit more complex.
// Note that using reset(user_load_multiple() directly is not E_STRICT compatible.
$users = user_load_multiple(array(), array('name' => 'admin'));
$user = reset($users);
?>

So, the easiest way to catch these is to search for "_load(array".


I ran into the same array_flip error over the weekend, trying to upgrade a custom module to Drupal 7. The problem is that a nested array is getting passed into DrupalDefaultEntityController, but it's expecting a simple array of integers or strings. In my case, I was passing in a nested array in to EntityFieldQuery, when it wants just an array of integers.

To better track down the code that is calling DrupalDefaultEntityController, try inserting the following before line 178 in entity.inc:

drupal_set_message(var_export(debug_backtrace(), TRUE));

... or preferably, install the Devel module and try inserting the following instead:

dpm( debug_backtrace() );

The problem comes up when you're using Organic groups field access (Organic Groups 7.x-1.3)

You can usually disable that sub-module unless you do field level access control with OG.

http://drupal.org/node/1102570#comment-5626946