I have come across the following error when clearing cache on my site (which appears multiple times after the cache clear):

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /mnt/www/html/reachlocaldev/docroot/includes/entity.inc).

To debug, I put in a breakpoint (stop_here()) along with some debug text, and used xdebug to trace back through each function until I found the offending issue.

Inside of user.module, starting near line 323, there is an if statement to check that $picture_fids is not empty. However, right after cache clear, if you call user_load and the following conditions are true:

- User pictures are enabled
- A given user does not have a picture (in the database, the 'picture' field in the users table is 0)

Then this if statement will have an array with a single value, false (or 0), passed to it. This will get through the if statement, get fed to file_load_multiple(), and then on to DrupalDefaultEntityController->load(), where the error is reported. I have found two solutions so far:

1) Give the user in question a profile picture, or
2) Modify the if statement per the changes in the patch I uploaded

I have also added a screenshot of the xdebug output. Is you will see, I am using OG, but after looking carefully in og_context.module I see that there is nothing unusual there; the module is merely calling user_load() on the current user. For the "key/value" text in the screenshot, I added a little debug text near line 175 to see what was in the $ids parameter.

Needed feedback

While the patch "works," I see that multiple-value arrays are being passed to the if statement at line 324 in user.module, so there might need to be a better check than just seeing if the first item in the array is 0. Perhaps if all items are 0/false.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

laboratory.mike created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, user-cache-clear-issue.patch, failed testing.

Version: 7.39 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.