Updated: Comment #25
Problem/Motivation
This problem happen most for user who upgrading from Drupal 6 to Drupal 7. Error show up because image field was set a default image.
Proposed resolution
By removing default image previously set in all image field resolved the problem. This happen because during migration there is no uploading default image occur.
Remaining tasks
User interface changes
API changes
Original report by @kannary100
Log:
php
Date Wednesday, March 23, 2011 - 03:16
User superadmin
Location http://drupal7/content/xxxxx
Referrer http://drupal7/content/xxxxx
Message Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 177 of /Users/nitok/Sites/drupal7/includes/entity.inc).
Severity warning
Hostname 127.0.0.1
System Information
System: Mac OSX Snow Leopard 10.6.6
PHP 5.2.17 (cli) (built: Jan 20 2011 06:38:43)
Zend Engine v2.2.0
Error occurs in the following scenarios:
- When running cron (manual or automatic)
- When viewing or editing content that has media.
- When logging in
May have been triggered by Video module, but I find not trace back to it. Issue begun after latest Drupal update and while working with Video Module
Modules Installed
Package Name Version
@font-your-face @font-your-face (fontyourface) 7.x-1.1
@font-your-face Common fonts (common_fonts) 7.x-1.1
@font-your-face Font Squirrel API (fontsquirrel) 7.x-1.1
@font-your-face Google Fonts API (google_fonts_api) 7.x-1.1
CCK CCK (cck) 7.x-2.x-dev
CCK Content Migrate (content_migrate) 7.x-2.x-dev
Chaos tool suite Bulk Export (bulk_export) 7.x-1.x-dev
Chaos tool suite Chaos tools (ctools) 7.x-1.x-dev
Chaos tool suite Page manager (page_manager) 7.x-1.x-dev
Chaos tool suite Stylizer (stylizer) 7.x-1.x-dev
Charts Charts (charts) 7.x-1.x-dev
Charts Charts System (charts_system) 7.x-1.x-dev
Charts Google (google_charts) 7.x-1.x-dev
Core Block (block) 7.x-dev
Core Blog (blog) 7.x-dev
Core Color (color) 7.x-dev
Core Contact (contact) 7.x-dev
Core Content translation (translation) 7.x-dev
Core Contextual links (contextual) 7.x-dev
Core Dashboard (dashboard) 7.x-dev
Core Database logging (dblog) 7.x-dev
Core Field (field) 7.x-dev
Core Field SQL storage (field_sql_storage) 7.x-dev
Core Field UI (field_ui) 7.x-dev
Core File (file) 7.x-dev
Core Filter (filter) 7.x-dev
Core Help (help) 7.x-dev
Core Image (image) 7.x-dev
Core List (list) 7.x-dev
Core Locale (locale) 7.x-dev
Core Menu (menu) 7.x-dev
Core Node (node) 7.x-dev
Core Number (number) 7.x-dev
Core Options (options) 7.x-dev
Core Path (path) 7.x-dev
Core PHP filter (php) 7.x-dev
Core RDF (rdf) 7.x-dev
Core Search (search) 7.x-dev
Core Shortcut (shortcut) 7.x-dev
Core Statistics (statistics) 7.x-dev
Core Syslog (syslog) 7.x-dev
Core System (system) 7.x-dev
Core Taxonomy (taxonomy) 7.x-dev
Core Text (text) 7.x-dev
Core Toolbar (toolbar) 7.x-dev
Core Update manager (update) 7.x-dev
Core User (user) 7.x-dev
Database Schema (schema) 7.x-1.x-dev
Date/Time Date (date) 7.x-1.x-dev
Date/Time Date API (date_api) 7.x-1.x-dev
Date/Time Date Popup (date_popup) 7.x-1.x-dev
Date/Time Date Views (date_views) 7.x-1.x-dev
Development Devel (devel) 7.x-1.x-dev
Development MyHook (myhook) 7.x-1.x-dev
Development MyHook Admin (myhookadmin) 7.x-1.x-dev
Facebook Social fb_social (fb_social) 7.x-2.x-dev
Plugins
Facebook Social fb_social comments (fb_social_comments) 7.x-2.x-dev
Plugins
Facebook Social fb_social like (fb_social_like) 7.x-2.x-dev
Plugins
Facebook Social fb_social recommendations 7.x-2.x-dev
Plugins (fb_social_recommendations)
Features Features (features) 7.x-1.0-beta1
Features Video Presets (video_presets) 7.x-1.0
Fields Fieldgroup (field_group) 7.x-1.x-dev
Fields Font Reference (font_reference) 7.x-1.1
Fields Node Reference (node_reference) 7.x-2.x-dev
Fields References (references) 7.x-2.x-dev
Image Imagecache Actions (imagecache_actions) 7.x-1.x-dev
Image Imagecache Autorotate (imagecache_autorotate) 7.x-1.x-dev
Image Imagecache Canvas Actions 7.x-1.x-dev
(imagecache_canvasactions)
Image Imagecache Color Actions (imagecache_coloractions) 7.x-1.x-dev
Image Imagecache Custom Actions 7.x-1.x-dev
(imagecache_customactions)
ImageAPI ImageAPI (imageapi) 7.x-1.x-dev
ImageAPI ImageAPI GD2 (imageapi_gd) 7.x-1.x-dev
ImageAPI ImageAPI ImageMagick (imageapi_imagemagick) 7.x-1.x-dev
Media Flowplayer API (flowplayer)
Other Advanced help (advanced_help) 7.x-1.x-dev
Other Backup and Migrate (backup_migrate) 7.x-2.x-dev
Other Colorbox (colorbox) 7.x-1.0-beta3
Other Custom Formatters (custom_formatters) 7.x-1.x-dev
Other Entity API (entity) 7.x-1.0-beta8
Other Entity tokens (entity_token) 7.x-1.0-beta8
Other Follow (follow) 7.x-1.x-dev
Other getID3() (getid3) 7.x-1.x-dev
Other HTML Purifier (htmlpurifier) 7.x-2.x-dev
Other Libraries (libraries) 7.x-2.x-dev
Other MediaElement.js (mediaelement) 7.x-1.0
Other Menu attributes (menu_attributes) 7.x-1.x-dev
Other MimeDetect (mimedetect) 7.x-1.x-dev
Other Multiple forms (multiform) 7.x-1.0-beta1
Other Pathauto (pathauto) 7.x-1.x-dev
Other Permissions Lock (permissions_lock) 7.x-1.0
Other Role delegation (role_delegation) 7.x-1.x-dev
Other String Overrides (stringoverrides) 7.x-1.x-dev
Other String Overrides Migrate (stringoverrides_migrate) 7.x-1.x-dev
Other Strongarm (strongarm) 7.x-2.0-beta2
Other Token (token) 7.x-1.x-dev
Other Transliteration (transliteration) 7.x-3.x-dev
Other User protect (userprotect) 7.x-1.0
Panels Panels (panels) 7.x-3.0-alpha
3
Panels Panels In-Place Editor (panels_ipe) 7.x-3.0-alpha
3
Rules Rules (rules) 7.x-2.x-dev
Rules Rules Scheduler (rules_scheduler) 7.x-2.x-dev
Rules Rules UI (rules_admin) 7.x-2.x-dev
Spam control CAPTCHA (captcha) 7.x-1.0-alpha
2
Spam control Image CAPTCHA (image_captcha) 7.x-1.0-alpha
2
Spam control reCAPTCHA (recaptcha) 7.x-1.0
Spam control reCAPTCHA Mailhide (recaptcha_mailhide) 7.x-1.0
Statistics Google Analytics (googleanalytics) 7.x-1.1
Taxonomy Taxonomy Manager (taxonomy_manager) 7.x-1.x-dev
Taxonomy Menu Taxonomy Menu (taxonomy_menu) 7.x-1.x-dev
ThemeKey ThemeKey (themekey) 7.x-1.x-dev
ThemeKey ThemeKey Debug (themekey_debug) 7.x-1.x-dev
ThemeKey ThemeKey UI (themekey_ui) 7.x-1.x-dev
User interface Active Tags (active_tags) 7.x-2.x-dev
User interface CKEditor (ckeditor) 7.x-1.x-dev
User interface elFinder (elfinder) 7.x-1.x-dev
User interface jQuery plugins (jquery_plugin) 7.x-1.0
User interface Sweaver (sweaver) 7.x-1.x-dev
Video Video (video)
Video Video UI (video_ui)
Views Views (views) 7.x-3.x-dev
Views Views Bulk Operations (views_bulk_operations) 7.x-3.x-dev
Views Views exporter (views_export) 7.x-3.x-dev
Views Views PHP (views_php) 7.x-1.x-dev
Views Views UI (views_ui) 7.x-3.x-dev
| Comment | File | Size | Author |
|---|---|---|---|
| #139 | entity_load_exception-1102570-139.patch | 1.13 KB | bonrita |
| #95 | entity-array_flip_warning-1102570-95.patch | 1.29 KB | kimwes |
| #84 | entity-array_flip_warning-1102570-75.patch | 732 bytes | milos_silni |
| #32 | Screen Shot 2011-10-28 at 4.33.32 PM.png | 30 KB | silverfly |
| #27 | entity_load_exception-1102570-27.patch | 1.23 KB | girishmuraly |
Comments
Comment #1
alvmarveg commentedI have the same warning.
Comment #2
Chris CharltonI get this warning on a brand new D7 site. Unsure what's triggering it, but I recently got it on the Block administration screen (in the overlay).
Comment #3
jasonabc commentedAm getting this as well when I try and run update.php on D7. Anyone got any ideas??
Comment #4
fagoUsually errors like this are caused by invalid entity_load() calls, i.e. passing an $id array containing non-IDs (= no STRING or INTEGER values).
Comment #5
jaiiali commentedsubscibe
Comment #6
Aniara.io commentedSubscribing
Comment #7
JoeJava commentedJust got his error. Added the Video module and added a video filed to a content type and now I get this same error message.
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 177 "long directory structure followed by" includes\entity.inc)
Comment #8
bertus commentedsubscibe
Comment #9
darq88 commentedsubscibe
Comment #10
garron commentedsubscribe
Comment #11
corporaljolly commentedsubscribe
Comment #12
zincdesign commentedsubscribe
Comment #13
b-prod commentedI had this bug because of page title module which calls user_load() function with an array as argument instead of a string.
You should look for a module that do the same kind of mistake: calling user_load() or node_load() with an array of ids (that was the correct way for D6, not D7).
Comment #14
ericxb commentedyet another "me too:"
Drupal version 7.2
Error popped up while adding another text format:
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 177 of /home/kfarms/drupal7/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 353 of /home/kfarms/drupal7/includes/entity.inc).
Comment #15
mikkovedru commentedHave the same problem. Came (again?) after latest Drupal 7.6 update.
The error I get is:
I also get an error (might be unrelated to the problem above):
Hope that helps to localize the root of the problem.
This error might somehow be related to Organic groups module ( http://drupal.org/project/og ). People, please try to install the latest dev version and tell us all if that worked.
Comment #16
fagoProbably it would be a good idea to throw an exception in entity_load(), similar to #1067750: Let Field API fail in a tale-telling way on invalid $entity ? I guess that would help people to identify what's going wrong?
Comment #17
jimbaer commentedOK, when working as administrator and making any edit or save process, I also irregularly received these messages, loud and red on the top of my live page, more discreetly on admin pages, sometimes two or three pairs of the following:
The warnings are usually sparked when a new user opens an account and attempts, or does log in. Sometimes one attempt to log in will spark three pairs of warnings.I'm unable to discover the exact process the user works through to create the warnings, but the user sees nothing untoward, and the site otherwise seems to carry on working satisfactorily .
I posted this on the Marinelli bugs, but recieved no feedback apart apart from finding one other sufferer. I'm D 7.8, Marinelli 7.x 3 beta 11. I've tried enabing and disabling user pictures (the possible origin of the first notice) but it makes no difference.
My php is too limited to trace the story further I'm afraid. Detailed configuration:
Comment #18
aspilicious commentedThose marinelli reports are cause by bad marinelli code. (almost 100% sure)
Comment #19
dddave commentedSetting back against dev. Agree with #18 that those Marinelli notices are not caused by a core issue.
Comment #20
jimbaer commentedOK, but shouldn't core tolerate or reject bad code inputs? It looks as though there have been other examples of this warning occurring without marinelli being present.
Comment #21
aspilicious commentedjimbaer that is not possible... The only thing it can do is produce better errors on failure.
Comment #22
jimbaer commentedThanks aspicilious. I've traced back through the coversations referred to above and i see what you mean. I'm taking this back to the Marinelli site and referring to this conversation. . . http://drupal.org/node/1253342
Comment #23
bmango commentedI'm getting the following error:
on my site and I don't have marinelli. Other people have also said that the page title module can cause this problem, and I don't have this either. The error message is popping up quite frequently and seemingly randomly. It seemed to begin when I started using the profile picture field. However, I have since stopped using it and I'm still getting the error messages. I'm not quite sure what I can do next, apart from turning messaging off, to fix the message.
I'm using D7.8.
Comment #24
john_b commentedI have spent a day on this after upgrading a D6+Ubercart site to D7+UC3. It affects most but not all Pages including at least one product, including a catalogue view. Not on other pages. Not sure whether this is a problem because the Drupal is trying to execute array_flip() on a nested arrays when rendering product image field (even on a product where no image has been uploaded).
Comment #25
john_b commenteddeleted. I thought I had traced my problem but it is back.
EDIT it was corruption in the database after upgrading D6>D7 and migrate content type Product. The corruption involved the keys for (apparently no longer available) feature of using a default image where no images is uploaded.
Comment #26
theapi commentedHere's a patch that filters the ids array so that array_flip() can be used without causing the warning, by filtering out ids that are NULL or FALSE.
Comment #27
girishmuraly commentedI agree with #16 a proper exception on entity_load() would be kind to developers. More contrib modules are going to have bugs because they would find it very very difficult to trace back from the current array-flip() error message.
Attached is a patch on entity_load(). This will not solve the issues, but will throw an exception if non-string or non-integer values are passed in. This should help developers to trace the problems a little more easily and shifts the illegible php error from appearing downstream.
Comment #28
girishmuraly commentedComment #29
theapi commented#27 Throwing an exception doesn't fix the problem, just highlights it.
entity.inc uses the function array_flip() without checking what it is passing to it, which causes the warning.
It is also possible that the methods in entity.inc are called without using entity_load() so the exception would be bypassed.
Comment #30
girishmuraly commented@PeterC, do you have specific instances where entity_load() is bypassed?
I think entity_load() should be called every single time, which then delegates the call to the appropriate entity controller, like entity or entitycache, for example.
Yes, you are correct, as I mentioned in #27 it is not so a solution to solving any of the problems that cause the array_flip() error. Instead of just patching every entitycontroller, I think the problem should be highlighted way before in the parent function and all exception handling should be taken care of before passing sanitised values to the children. Else, there will be duplicate code and error checking all over the place.
With patch #27 the idea is that individual modules should know that it is them that have caused the exception and should fix them.
Comment #31
girishmuraly commented@PeterC, you are right in that method load() in DrupalDefaultEntityController is a public method and can be called outside of entity_load(). So yes, there needs to be some refactoring that needs to happen, probable on DrupalEntityControllerInterface itself?
* A validate() function could be added to the interface
* DrupalDefaultEntityController implement validate() to do basic validation such as a proper array_filter()
Note: The array_filter in #26 is not foolproof because it filters out value 0, although it should not as its a perfectly valid item (user id 0). It should only filter non-string & non-integer, something like
$ids = is_array($ids) ? array_filter($ids, array(__CLASS__, '_check_ids')) : FALSE;and implemented as
Thoughts?
Comment #32
silverfly commentedHaving the same issue. I thought it might be helpful to know that this occurred when I gave permissions to anonymous users to view user profiles.
Comment #33
ianraf commented#26: array_flip_warning-1102570-26.patch queued for re-testing.
Comment #34
ramu_bharu commentedThis is helped more to me...Thanks alot...
Comment #35
Pimmy commentedI might be off my head, but I see inconsistency between patch #26 and the code for Entity API 7.x-1.0-rc1 (what I am running on D7.9):
The patch replaces the below line in './entity/includes/entity.inc':
while I do not have this line at all in my './entity/includes/entity.inc'. I do have similar line in './entity/includes/entity.controller.inc':
Can anyone shed some light please?
Thanks,
Pimmy
Comment #36
khiminrm commentedSubscribe
Comment #37
sun-fire commentedSubscribe. The same.
Comment #38
Jamie Holly commentedHopefully we can get some attention on this issue. Last night I was looking to see if there had been any progress on this issue because it again. crept up on me while doing work on a D7 site. Some Googling returned some interesting and rather depressing results. Googling for "Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()" on drupal.org returned 919 results (see here). I went through a few pages and noticed tons of issues on this in all kinds of different projects. That makes me believe this is either a core issue or a documentation issue, where people aren't doing something right. I would lean a lot more towards it being a core issue, improper exception handling, etc.
This issue has been around for a long time also. I found one issue I was on that was started in April of 2010 about this issue, that was eventually closed and marked a duplicate of this issue. Somehow this one made it through all the beta and release candidates of D7, most likely because it's seems so random.
I also did a search for "Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()" on the Google overall and got over 18,000 results. Sure enough you start going through them and they are Drupal 7 sites showing this error. That really made me cringed to see my beloved Drupal showing so many sites with a big warning on top.
Comment #39
girishmuraly commented@Jamie Holly, just curious if the patch in #27 helped you find the actual issue in your sites so that you could debug from there?
Comment #40
gaiello commentedSubscribe
Comment #41
Jamie Holly commented@girishmuraly
I'll give #27 a try when I get a chance. I'm pushing a deadline for a rather big client, so I came up with a workaround similar to #26 to get rid of the warnings, which passed the tests on this setup.
It looks like #27 will be good for tracking down what is causing the problem. It looks like most of the problem is coming from contrib, but that does raise the question of why and what can be done in core to prevent the problem in the future.
Comment #42
gaiello commentedI don't know if this helps those investigating this issue but with the patch from #27 I get the following exception error:
On my dev site this only occurs on /node/add/FORM of content-type forms with added fields. All roles except administrator get the error on those add forms. Edit (/node/NID/edit) does not throw the error for any users.
-George Aiello
Comment #43
Jamie Holly commented@gaiello -
Admins not getting the notice is something I also noticed (well this time - I've had it before in other situations where admins do see it). Are you doing anything that limits the field permissions to non-admin users? I've got a feeling that may have something to do with it. In the case I had yesterday, it appears to be something with field level permissions in OG.
Comment #44
girishmuraly commented@gaiello from your error report it seems to me like some module (contrib/custom) is trying to load a node in the node_form. Possibly in a node_form_alter somewhere, without giving heed to the fact that the node object would only exist if you are editing an existing node.
Comment #45
gaiello commented@Jamie Holly (and @girishmuraly)
I don't have field level permissions set on this dev site (yet) but after reading your comments (#43 / 44) I have confirmed that the problem /node/add/FORMs only apply to OG group content types, at least in my case. To confirm this I just added a couple of the same fields from one of the OG group content types to the article content-type which is not associated with OG and the /node/add/article form loads fine for all roles granted permission to add the article content-type.
-George Aiello
Comment #46
gaiello commentedAll ...
My instance of this issue was fixed by updating OG to 7.x-1.x-dev.
Thanks for the help!
-George Aiello
Comment #47
Jamie Holly commentedSo it sounds more like we have a case where contrib isn't really doing something right and that's causing the problem. Now the big question would be how to address this so it doesn't break contrib? What I've seen going through the issue queue of numerous projects is that this issue is active, but people always have problems reproducing it. That just adds complexity to the problem.
A solution might be something along the lines of an exception like #27 in conjunction with a docs page on proper entity loading. A link to that page could then be given in the exception as kind of a "hey read this" to people who write modules. At least when people post about the problems in the issue queue, they would most likely copy the link with the exception message.
Comment #48
girishmuraly commentedTrue, and it would be nice to create an issue in OG module that would link to this thread with the appropriate fix (upgrade to 7.x-1.x-dev).
Many contrib modules may stumble upon this bug. I think this harsh failure message was intended to get contrib modules fixed. Hence we need to report issues in the appropriate modules as we find them.
Thanks for your messages @gaiello and @Jamie Holly.
Comment #49
Pimmy commentedCould someone please explain me why there is inconsistency between the patch #26 and code for Entity API 7.x-1.0-rc1 (post #35).
Thanks,
Kliment
Comment #50
dave reidThis is a duplicate of #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID
Comment #51
jessebeach commentedJust to note,
user_loadaccepted an array as a parameter in D6. This function now accepts an integer as a parameter in D7.http://api.drupal.org/api/drupal/modules--user--user.module/function/use...
Comment #52
toddwoof commentedIn case this is useful to anyone: In my D7 site, "Can only flip STRING and INTEGER values!" error resulted from PHP visibilty snippets in block settings that had worked fine in D6. It was fairly simple to replace them, in this case, with regular visibilty settings (non-PHP, path names and wildcards) and turn off the PHP module; but presumably re-writing the PHP based on the D7 requirements would also be an option.
Comment #53
vlemaire commentedComment #54
xuxizh commentedsubscibe
Comment #55
kclarkson commentedIs there a clear cut solution to this?
I have read through all the comments but it is unclear what I should do to fix.
Is it Drupal core issue or an Entity API issue?
Comment #56
brightbold@kclarkson Since Dave Reid closed this as a duplicate of a Drupal core issue, presumably it's a core issue. From that thread, it looks like the patch in #1003788-57: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID has been successful in solving the problem in D7.
Comment #57
kclarkson commented@BrightBold
I went to the other page but it appears as though the solution is for Drupal 8.
In addition there are so many patches its hard to know which one to patch.
As a site builder with amateur coding skills this bug is driving me crazy.
Comment #58
brightbold@kclarkson - the patch in #57 that I linked to has "drupal7" in the patch name, so I'm pretty sure it's for Drupal 7! It looks like it was made for Drupal 7.9, but the most recent comment in that thread indicates that someone has used it successfully with Drupal 7.10.
I feel your Site-Builder-Trying-To-Handle-Core-Patches pain! It's definitely confusing at first but you will get the hang of it. In a case like this, with a long thread containing multiple patches, I often read up from the bottom, looking for the most recent comment to report success with a patch, and then see which comment they refer to so I can find the patch that worked for them. Then I read the comments in between those two, to see what other people think of that patch, and to make sure there's not a better one in between that the most recent commenter missed.
Also, while you're smart to check the version on the issue so you're not trying to apply a patch for a different version, you should know that once development has started on the next version of Drupal, core bugs usually get worked on in the newest version first and then backported to the current version. So even though the issue says 8.x, there may be backport patches to 7.x in the thread.
Hope that's helpful!
Comment #59
jjmackow commentedthe patch (1003788-57-drupal7.patch )referenced in #56 cleared up my issues with this error also.
Comment #60
DavilaG commentedSame to me, my issues where fixed when upgrading to og 7.x-2.x-dev, so definitely an OG Module issue.
Just for your information, I was getting this error when creating new group content as a registered user. I wasn't getting it as an administrator.
Comment #61
yustos commentedI have a similar message when creating new content for the organic group as a registered user. If I create it as an superadmin, this error is absent.
Comment #62
kclarkson commented@brightbold
Thank you for the encouragement :) I will give this a shot
Comment #63
zanoman commentedsubscribe
Comment #64
vasna sdoeung commentedIt seems the issue only shows up when Organic groups field access module is enabled.
Comment #65
copossum commenteddisabling OG field access did the trick for me too
Comment #66
gaëlgDisabling OG field access worked for me too. Is this issue really a duplicate?
Comment #67
a.siebel commentedI have this error without og field access enabled.
Comment #68
arnoldbird commentedThe patch in #27 enabled me to track down the problem in my site. The exception mentioned profile2 and I was then able to find a call to profile2_load() in my custom module where I was not passing a numeric $pid. It was then an easy fix in my custom module. Definitely try the #27 patch if you are running into this problem, but note that any module mentioned in the exception might not actually be the one that's to blame.
Comment #69
javdich commentedI confirmed #65 and #66. After uninstalling OG field access the error message went away.
Comment #70
tomogden commentedIf I ever enabled OG Field Access, it's been long since uninstalled. I think you've only got a partial solution here.
Comment #71
djween commentedI have OG field access installed. I applied patch from #56 to entity.inc and my issue was resolved.
Comment #72
arnoldbird commentedI started getting array_flip errors again today. This time the patch in 27 did not help me narrow it down. Using the patch in 27, I see:
Exception: Entity id can only be a string or integer, for entity '<em class="placeholder"></em>' of type '<em class="placeholder">node</em>'It seems that some code somewhere is trying to use a string of HTML as an entity_type, which obviously is not going to work. Grepping through the code to try to find the offending module, I have come up empty. Disabling recently installed modules also did not help.
So, I could not find the cause of the problem this time, but noticed it was happening only for some users, and then found that if I log in as admin and save the user's account, the problem goes away for that user. I have to repeat the exercise for every user account. Fortunately it's a dev site with only a few users. It would be nice to be able to pinpoint the offending code.
ps -- The next day (today), the bug came back. Damn, I would love to know where this is coming from.
Comment #73
groovehunter commentedget it on a node view with field for taxonomy terms;
terms are missing on some items.
use dev version? not urgent here, just subscribing
Comment #74
vyasamit2007 commented#26: array_flip_warning-1102570-26.patch queued for re-testing.
Comment #75
yudarik commentedI get the same error, for a non-admin member, on a week-view calendar. The view displays all events of the current week, assosiated with OG nodes. When loged in as admin, I don't see this error at all.
The error accures for me when tring to apply colored stripes based on Organic group, rathar than based on taxonomy on calendar legend properties. Switching back to taxonomy based legend, removed the error.
Comment #76
katannshaw commentedDrupal 7.12
SQL Server Driver for Drupal 7
PHP 5.3
IIS 7.5
I receive the same error when logging in as an "Author" role and trying to create a new "Article" (Note: This only happens with Articles and Posts.). This error did not happen for the Administrator role.
Disabling OG removed this error for me as well.
Comment #77
wielrijder commentedDitto on disabling OG Field Access. It solved the problem...I was only getting the warning when adding nodes to content types with an OG field. It had been occurring for Admin roles too.
Comment #78
cknoebel commentedI had this problem and solved it thanks to a lead from http://drupal.org/node/1003788#comment-5206002. Here's what happened: I migrated a site from D6 to D7.12. I discovered the error on only one custom content type out of eight. I disabled all modules to no effect. The patch in http://drupal.org/files/1003788-57-drupal7.patch worked but I kept digging.
In the content type that threw the error, I had one custom field, an image field that was set to show a default image when none was uploaded by the user. Not every node threw the error. Alan D. in 1003788#comment-5206002 suggested looking at the field tables for a non-numeric entity_id. Couldn't find one. I did see in the field table for my troublesome content type that the number of records didn't match the number of nodes for that content type. I thought they should have since I specified a default image. I compared the nodes with and without the error to the table and saw the ones that threw the error were supposed to show the default image. I checked and found the default image (or a reference to it) was lost in the upgrade. I added a new one and the errors were gone. Incidentally, I saw the error when I edited the custom image field in the "manage fields" interface when updating the default image. That error is gone, too.
Comment #79
cknoebel commentedI should mention my site does not use OG.
Comment #80
dkeays commentedI ran into this when putting custom PHP code in template.php that loaded the user from a field attached to the node. I was doing the same thing in several times but only one line was generating the error.
I solved it by simply type-casting the variable passed to user_load()
BAD: $account_locked = user_load( $uid_locked);
GOOD: $account_locked = user_load((int) $uid_locked);
I'm going to write this off as an example of the delicate variable handling in PHP.
Comment #81
NowThatsCookin.Com commentedForgive a newblar question, but where do you go to disable OG Field Access.
I have looked at the modules, and do not see it there, but will look it over again. I have been known to be blind in one eye, and deaf in the other. :)
I too am getting this error on my site.
Frank
Comment #82
katannshaw commented@NowThatsCookin.Com
It took me a bit to figure it out, and this helped me: http://drupal.org/node/1463614
This is the line that helped me:
Delete all OG fields at admin/reports/fields
Disable and remove any features modules that require OG
I found a few fields that used OG, and once they were gone, I was able to disable OG. I ended up uninstalling it all together because of the errors I was getting. Hope it helps.
Comment #83
szt commented#80 works for me. (I've no OG as well)
Thanks dkeays!!!!!!!!
Comment #84
milos_silni commentedhere is mine sollution .... caused when submiting new og group content
Comment #85
scottholmes commentedI'm currently having the same problem. I do not have OG installed. In my case it appears when using the Zen STARTERKIT theme without modification (aside from changing the theme name). The problem does not appear when using Zen or Garland. This is the 7.14 version of Drupal and the error occurs at line 355 of entity.inc
I've just now tried using the Omega starter theme and the same issue arises. The site is a migration from a drupal 6 site so perhaps there are problems with the node records. The errors do not occur on the front page, which is not a node. Nevertheless, the errors do not occur using Zen as default nor Garland.
Comment #86
joemaine commented...just posted this as a Zen issue...
I'm receiving 2 each of the following warnings when using the Zen Sub-theme Starter Kit:
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of /home/XXX/XXX/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/XXX/XXX/includes/entity.inc).
I do not get the warnings when using any of the Drupal base themes, or the Zen 7.x-3.1 theme. The warnings appear with either a plain starter kit profile or a customized starter kit profile. The warnings do not appear on every page; pages built from views seem to be exempt from the warnings.
Contributed modules don't seem to affect the warnings; the warnings appear regardless of modules being enabled or not. ...and the warnings occur from both IE and FF.
If this occurred in all themes I'd be tempted to think if was the entity module; but it only happens with the Zen Sub-theme.
Comment #87
scottholmes commentedI put a dpm($ids) call in entity.inc line 178 and found that the fourth time this call was made produced the offending $ids value: ... (Array, 1 element)
0 (Array, 1 element)
nid (String, 1 characters ) 1
This occurred while displaying the default 404 error page. (deliberately). How do I track back to find where this particular instance originated. If I'm counting correctly this point in entity.inc was hit fourteen times. Only the fourth time did an error occur.
Comment #88
Jamie Holly commentedyou can do a debug_backtrace() to get the callstack.
Comment #89
mmll commentedGetting it while grouping taxonomy views with image field (excluded from view) and if there is no nodes with given taxonomy.
Comment #90
Patricia_W commentedI'm also getting this error after I installed CiviCRM on my site. (I am getting it anytime I try to access reports after creating a report from a template. I just deleted the report and the error went away.)
Comment #91
aspilicious commentedThat means there is an issue with civicrm
please report the issue there.
Comment #92
byheo commentedNeed to filtering null values in $ids.
line number 178 and 354 in entity.inc
array_flip($ids) --> array_flip(array_filter($ids, 'strlen'))
Comment #93
rafinskipg commentedI have drupal 7.14 and it happened to me in a views page. This comment solved my issue, thanks
Comment #94
mile23I'm getting this a lot in a bare-bones D7.15 install, when I call user_load_by_name('literal name string').
Comment #95
kimwes commented#92 comment's changes worked great for me too. I created a patch from them here.
Comment #96
brulain commentedSubscribing.
After migrating D6 -> D7, this warning only displays on the Drupal search results page.
Comment #97
liquidcms commentedmy guess would be the patch in #95 won't get committed as i think people are suggesting that these errors are caused by downstream modules which are making bad calls to entity api (and therefore not a core bug) - that being said; the patch does get rid of the warnings for me as well. :)
Comment #98
byheo commented#95: entity-array_flip_warning-1102570-95.patch queued for re-testing.
Comment #99
aspilicious commentedDo a backtrace of the warnings and you'll see which module performs bad calls to entity api. This indeed wont be fixed unless there is a good reason. People should fix their contrib code. Core should not babysit broken code.
Comment #100
IreneKraus commentedI've just joined as a follower on this as I'm getting this error on a fresh rebuild of an existing site (running Drupal 6). Seeing as the database associated with that site was the same one from Drupal 5, I thought it high time I did a complete re-build so as to ensure any lingering odd code was purged out. From what I gather reading the reports here, this has to do with faulty code for one of the contributed modules. Someone mentioned doing a backtrace operation so as to sort out which one. Any advice on how to do such a thing?
Comment #101
nagba commentedI agree with #99. Fix the module in question instead of adding safeguard.
Comment #102
nagba commentedIrene Kraus: Edit the line in the file where the error is thrown and before the actual error I'd add the following:
Comment #103
jessebeach commentedConsensus seems to be that issues arise with bad data and should be corrected at the offending module level, not by adding a safeguard to DrupalDefaultEntityController that would mask deeper problems. Having an error here is a warning to developers that they are using the D7 APIs incorrectly.
I'm marking as closed.
Comment #104
kenorb commentedPlease refer to the DrupalEntityControllerInterface implementation.
http://api.drupal.org/api/drupal/includes!entity.inc/interface/DrupalEnt...
Also some pages and articles:
http://drupal.org/node/878784
http://drupal.org/node/1026420
http://groups.drupal.org/entity-api
http://www.trellon.com/content/blog/creating-own-entities-entity-api
Duplicates:
#1803048: Warning : array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController
Note for devs:
If somebody is having problem with:
"Fatal error: Maximum function nesting level of '100' reached" error while trying to use Entity API,
- check the common mistakes e.g.: #1440284: array_flip() warning following Fatal error: Maximum function nesting level #2nd patch
- if you're loading entity using %wildcard, make sure it doesn't have the name: module_wildcard_load
- check your code with Examples module
If your problem is not above, please report separate a support issue.
Comment #105
mile23Note also: Examples project has entity_example module which (hopefully) demonstrates best practices. Or at least doesn't throw this error. :-)
Comment #106
nafmarcus commentedI found that that adding the code from #27's patch with a call to debug_backtrace() lead me to the source of the problem quickly. Thanks.
Comment #107
errev commented#27: entity_load_exception-1102570-27.patch queued for re-testing.
Comment #108
errev commentedShould the patch be in the holder home\site\www\includes to be applied?
I can't apply it.
Comment #109
carligraph commentedthe patch #27 entity_load_exception-1102570-27.patch results for me in the following error:
Exception: Entity id can only be a string or integer, for entity '<em class="placeholder"></em>' of type '<em class="placeholder">file</em>' in _entity_check_ids() (line 7760 of /var/aegir/platforms/drupal-7.22/includes/common.inc).without that patch it looks like this:
Comment #110
carligraph commented@errev: yes, with "patch < file.patch"
Comment #111
nagba commentedPlease note, that this issue has been closed. The patches here are all about babysitting bugs coming from other modules, so not the best approach. I would suggest finding out what is the root cause of the issue and file a bug with the module responsible for it.
Comment #112
kiliweb commentedAs #106 said : adding the code from #27's patch with a call to debug_backtrace() help to find the source of the problem quickly.
Thanks you !
Comment #113
fraweg commentedHello,
This patch works... thaks a lot!
Best regards
Frank
Comment #113.0
fraweg commentedadd another use case
Comment #114
turbogeek commented#25 was the issue in my case, thanks John_B! After a D6 to D7 upgrade, removing the default image fixed the error.
Comment #115
jay.lee.bio commentedIn my case, I started getting this warning after installing Invite Notifications of Invite.
Comment #116
massiws commentedI get the same error installing Computed Fields; in $ids I see some NULL values, that I suppose to be the reason of the error.
Disinstalling the module don't make the message disappear.
Apply patch #27 fix the problem.
Comment #117
stephen ollmanI was getting this error after upgrading from D6 to D7.
One of my content types had an image field. I'm not sure if there was any customisation done to the output, but by simply adding a 1px by 1px transparent .png file as the default image for that field it removed this error.
Thanks to everyone above for their suggestions that lead me in the right direction.
Comment #118
yngens2 commentedPatch in #27 is giving:
Comment #119
parasolx commentedI'm facing same problem. Upgrading from D6 to D7 and these error come out.
Luckily #25 really solve my problem by removing DEFAULT images that have been set in previous Drupal version.
Latest patch doesn't help at all. It just create another error.
Comment #120
dgtlmoon commented#25 helped to identify the problem, still not quite how to totally fix it tho
perhaps a old field that wasnt upgraded from D6 properly?
Comment #121
dgtlmoon commentedTested on current dev
Comment #122
martin74 commented#80 worked for me
Comment #123
m33_nft commentedPath #95 Don't work for me. I change this:
if (!empty($this->entityCache)) {
if ($ids && is_array($ids)) {
foreach ($ids as $i=>$id)
{
if (is_array($id))
{
$ids[$i] = array_shift($id);
}
}
$entities += array_intersect_key($this->entityCache, array_flip($ids));
}
Comment #124
mile23Note that this issue is *closed*.
kenorb helpfully summarizes the conclusions in comment 104: https://www.drupal.org/node/1102570#comment-6756382
Basically: If you are seeing this error, it's because a module is implementing entity API incorrectly. Figure out which module it is, and then contribute to an issue for that module, and not here.
Comment #125
prsnjtbarman commented#84 solves the issue
Comment #126
leisurman commented#117
I upgraded from d6 to d7. some of the cck image fields had default images. And I did not delete them before upgrading to d7.
I was getting this error in d7 on every page
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/upgrade2a/includes/entity.inc).
I placed this inside /includes/entity.inc before line 178.
print_r($ids);
I reloaded aweb page and this was the result and I will trim it.:
Array ( [0] => 41 ) Array ( [0] => Array ( [filename] => how-to-thumbnail.jpg
[filepath] => sites/default/files/imagefield_default_images/how-to-thumbnail.jpg
[filemime] => image/jpeg [source] => default_image_upload [destination] =>
sites/default/files/imagefield_default_images/how-to-thumbnail.jpg [filesize] =>
2108 [uid] => 1 [status] => 1 [timestamp] => 1310043353 [fid] => 54019 ) ) Array
( [0] => 13218 [1] => 13213 [2] => 13154 [3] => 13141 [4] => 13134 ) Array ( [0]
=> 41 ) Array ( [0] => 41 ) Array ( [0] => 41 ) Array ( [0] => 41 ) Array ( [0]
=> 41 ) Array ( [0] => 41 ) Array ( [0] => 41 ) Array ( [0] => 41 ) Array ( [0]
The image how-to-thumbnail.jpg was a default image on the old d6 website. In the new d7 site its not there, so I uploaded a default image .
THe error went away. I could just ingore this and upload 1px by 1px transparent .png. Just like #117
I noticed is that my image field cck has 2 default images fields that I can upload a photo in, Why?
Comment #127
drupaleze commentedThis worked for me:
open /includes/entity.inc
uncomment $passed_ids = !empty($ids) ? array_flip($ids) : FALSE; i.e.
// $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;just before if ($this->cache && !$revision_id) {
comment $passed_ids = count($ids)>1 ? array_flip($ids) : FALSE;
save and clear cache via drush if you are having difficulty accessing the main site
Comment #128
hamrant commented#95 fixed my problem, thank you, kimwes
Comment #129
Chris CharltonSo am I correct in assuming this issue isn't truly resolved?
Comment #130
juankvillegas commentedI started receiving this error and it was caused by a module that I'm developing.
The cause was that I was trying to do
node_load($nid), but$nidwas set toFALSE.After modifying my code to do not use FALSE $nid, but 0 instead, the message disappeared.
Comment #131
arne_hortell commentedI fixed my situation doing this
In entity.inc, adding the below at lines
// ********************** My fix ***************
if (!empty($ids)) {
$this->cleanIds($ids);
}
// *******************************************
$passed_ids = (!empty($ids)) ? array_flip($ids) : FALSE; // previous line 179
and then everywhere i got an error message adding the fix, and
also in file entity.controller.inc, almost same places.
Then errors was cleared.
I run drupal 7.54
Comment #132
arne_hortell commentedReason is, $ids array is sometimes having strings, sometimes having integers and sometime having arrays !!!
And the arrays are the problem as the array[0] is the value to be used... and array_flip cant use that, therefore the error.
Comment #133
vali hutchison commentedLike arne_hortell above I was getting this error due to calling node_load($nid) when $nid was not an integer. So created a small helper function as below and then across the site in my code I replaced node_load with mymodule_node_load and this got rid of the error
Comment #134
zoplaka commented#95 works fine for me
Comment #135
kenorb commentedComment #136
remyyyyyThank you for the patch
Comment #137
Chris CharltonSeems like
node_load()would/could/should(?) have a safeguard for this, no?Comment #138
kris77 commented#95 works for me too...
I'm using Drupal 7.59...
it seems strange that this error in the official version has not been corrected yet.
Comment #139
bonrita commentedMake the patch added in comment 27 compatible with Drupal 7.61
Comment #140
timme77 commented#95 works for me!
Comment #141
aaldayel commented#131 works for me!