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.
Comment | File | Size | Author |
---|---|---|---|
Drupal - user load patch.png | 45.06 KB | laboratory.mike | |
user-cache-clear-issue.patch | 684 bytes | laboratory.mike | |
Comments