I have recently migrated my module to Drupal7 (on PHP Version 5.3.1) and now I am getting following errors:
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\Users\akulkarni\Desktop\xampp\htdocs\servicecasting\includes\entity.inc).
I have also tried upgrading other modules and core to latest versions as mentioned here http://drupal.org/node/1022736
entity 7.x-1.x-dev (2011-Jan-24), views 7.x-3.x-dev (2011-Jan-22), Drupal core 7.x-dev (2011-Jan-24), profile2 7.x-1.0-beta1, references 7.x-2.x-dev (2011-Jan-14), ctools 7.x-1.0-alpha2
I am not able to figure out what is exactly causing this error?
Edit:
According to http://php.net/manual/en/function.array-flip.php,
array_flip() returns an array in flip order, i.e. keys from trans become values and values from trans become keys.
Note that the values of trans need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be flipped.
I have done the var_dump($ids);
before line 178 in entity.inc ( $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
)
And it looks to me that key/value pair is always in correct format(?).
array
0 =>
array
'nid' => string '6' (length=1)
array
0 =>
array
'uid' => string '1' (length=1)
array
0 => string '0' (length=1)
array
0 =>
array
'nid' => string '7' (length=1)
array
0 =>
array
'nid' => string '4' (length=1)
array
0 =>
array
'nid' => string '8' (length=1)
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".