(why the issue was filed, steps to reproduce the problem, etc.)

Setup - I used a patched development version of Media and Media Gallery - see steps here:

Recreating the problem:
Error message "Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of [site_docroot]/includes/"

This occurred because I deleted 3 pictures. The error message is displayed for each picture deleted. It does not display if you don't delete any of your pictures after uploading them. The error is displayed for both the authenticated user that can upload the gallery and also visible to unauthenticated users.

Proposed resolution

(description of the proposed solution, the rationale behind it, and workarounds for people who cannot use the patch)
It appears that deleting an image from a media_gallery gallery is not handled properly - I am guessing that some database entries relating to the deleted image are not removed or "cleaned up".

Remaining tasks

(reviews needed, tests to be written or run, documentation to be written, etc.)
Repeat steps that reproduced the problem, to see that the error message does not now appear (once the fix is done.)

User interface changes

(new or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text)
The user should not need to do anything different when deleting an image.

API changes

(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate)
Wouldn't expect any API to change, unless it is something still under development in Media 2.x-dev or Media Gallery 1.x-dev

Original report by [username]

// Text of original report here.
(for legacy issues whose initial post was not the issue summary)

#6 Snapshot-09-11-2012-1147.png218.52 KBtherobyouknow


therobyouknow’s picture

Just some thoughts to help fix the problem:

Doing a search found a different problem but with a similar message, one of the remedies suggested may be useful for solving this issue:

Therefore, the thinking so far would be one or more of:
- to make code in more defensive - such a fix being similar to the remedy in:
- to make sure that the parameters are valid that are passed by the calling code to

Moloc’s picture

Status:Active» Postponed (maintainer needs more info)

Are you using media 2.x ? This issue sound like a duplicate of #1715422: Deleting a file without removing it from the gallery breaks that gallery. Can you confirm that?

therobyouknow’s picture

Yes, media 2.x - 7.x-2.0-unstable6 to be exact. I will look at the issue you mention but perhaps it is not a duplicate as in my case the gallery is not broken as such, it's just that the error message is shown for each image that I have deleted via the delete option that the media gallery provides - the other images still display OK. Thanks for your suggestion.

By the way, I have been able to use the development version of media gallery to get it working with media 2.x - credit to those who worked on media gallery (rather than myself). I have documented my steps to get it working here - comment 102:

therobyouknow’s picture

Drupal user @leanderl confirms they can reproduce my same problem in this issue, their comment is made in this other issue here:

therobyouknow’s picture

I can confirm that the root cause is that the entry for the deleted image is not removed from field_data_media_gallery_media table in the Drupal MySQL database. This is the equivalent of a null/dangling pointer in other software. The remedy would be to add code to the media_gallery to remove the entry from the field_data_media_gallery_media table.

The root cause is illustrated in the following screen shot showing the relationship between the error, the Drupal MySQL tables including field_data_media_gallery_media, and the media files themselves.

(locally on :- )

(same screenshot also available externally here:- )

A work around would be to do a standard MySQL delete/drop of the specific entries in field_data_media_gallery_media that refer now to the deleted files.

therobyouknow’s picture

new218.52 KB
therobyouknow’s picture

A work around would be to do a standard MySQL delete/drop of the specific entries in field_data_media_gallery_media that refer now to the deleted files.

I have tried this - my own suggestion - and it does not cause the error to no longer appear. Clean up to remove the deleted file references will also be necessary in the following database tables (but cleaning these up also still does not remedy the problem)

  • image dimensions
  • field_revision_field_file_image_title_text
  • field_revision_field_folder

So although I was correct to point out that there were references to deleted files in some MySQL tables. I was incorrect to assume that these are the only cause of the error message.

therobyouknow’s picture

Further update which eliminates the error message that this issue is about ("Delete image works but warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()" )


  1. After I cleaned up the references to the deleted files in the tables that I mentioned in comment #5 and comment #7
  2. I then went into Edit gallery: /node/22/edit did nothing here and clicked Save. The error does not now appear.

From this I'm wondering if it is necessary to clean up the entries myself in the database tables or just delete the images via the gallery, and then go into edit the gallery and just click save.

therobyouknow’s picture

Issue summary:View changes

Clarified setup to recreate the problem