Warning: array_flip(): Can only flip STRING and INTEGER values! I have a custom module that hooks into a commerce extension module.

The function splits a payment for a product and splits it to beneficiaries who helped create the product.

I use user_referance module in a field collection field in the product content type to store the beneficiary users from the system. The drupal system log shows this when running through the function

Warning: array_flip(): Can only flip STRING and INTEGER values! in      EntityAPIController-&gt;load() (line 219 of /www/opigno/profiles/opigno_lms/modules/contrib/entity/includes/entity.controller.inc).


Drupals error back trace function showed the error came from this line

  if (!empty($item_id)){
      $split_pay = commerce_funds_object_to_array(entity_load('field_collection_item',
array($item_id)));
  }


The function does run through fine but I'd like to squash any bugs that are appearing, the $item_id array only contains the user_ids of beneficiary users so i don't really understand why a non integer value is being passed
I had a similar issue, you just have to be sure it is an integer and not a string, also you can use entity_load_single:

if (!empty($item_id)){
$item_id = (int) $item_id;
  $split_pay = commerce_funds_object_to_array(entity_load_single('field_collection_item', $item_id));
}