Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have applied the patch in #792024: Form error after installing on drupal 7.0-alpha4 and everything seems to work. I can insert images and they get properly generated.
But after I enable Insert for a field, I get the following warning when editing the field, as well as viewing the nodes of that content type:
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 104 of D:\wamp\www\d7\includes\entity.inc).
This happens with Drupal 7 alpha 6, I did not experience it in alpha 5. Something must have changed between the alphas causing this.
Comment | File | Size | Author |
---|---|---|---|
#31 | insert_return_element-d7.patch | 584 bytes | quicksketch |
#27 | insert-7p2.patch | 2.59 KB | ebremer |
#13 | insert-850946-erratic-return.patch | 624 bytes | florisla |
#12 | image_field_default_image_should_be_string.patch | 759 bytes | florisla |
Comments
Comment #1
quicksketchI've reproduced this problem but I've decided not to spend more time on Drupal 7 until it stabilizes. I'd be happy to review any patches you can submit, but I looked at this for an hour or so and couldn't find the reason easily.
Comment #2
rfayConfirmed: I have this also. Just enabling the insert widget on an imagefield seems to bring it on.
I don't blame you for waiting for D7 to stabilize :-) We're only 9 months into code freeze.
Comment #3
rfayAs the "Send to text area" button is also missing, I assume that this is actually critical. Perhaps that's a different issue.
Comment #4
quicksketchI won't be working any more to fix D7 problems, but I'd be happy to apply any patches.
Comment #5
tsvenson CreditAttribution: tsvenson commentedThis error message has slightly changed in Drupal 7 beta 2:
Also, it does only seem to appear when you edit the field for the content type, it no longer shows up when you view or edit the nodes.
To be able to test this, you need the patch in #918958: file_directory_path is removed in D7, replaced with file_default_scheme.
Comment #6
florisla CreditAttribution: florisla commentedI'm pretty new to this, but the array that cannot be flipped looks like this:
(not sure about the words 'Upload' and 'Remove'; they are in Dutch on my install ('Uploaden'/'Verwijderen').
Comment #7
mlncn CreditAttribution: mlncn commentedCan't figure out where this is coming from– are we certain it's Insert causing this?
Comment #8
florisla CreditAttribution: florisla commentedNot 100% sure in my case. Will double check on a clean D7 beta2 install.
Comment #9
florisla CreditAttribution: florisla commentedDouble checked and confirmed.
It starts occurring after insert has been enabled for an image field. And very strange: it keeps occurring even when insert is disabled for that field, and even when the insert module is disabled.
Steps I took to reproduce (which may contain superfluous steps):
The
$ids
variable looks like this:Comment #10
florisla CreditAttribution: florisla commentedInvestigating...
Stack trace looks like this:
Comment #11
florisla CreditAttribution: florisla commentedAlso interesting to note: disabling the insert button on the field does not make the error go away (as mentioned in #9) unless you also change the 'Number of values' of the Image field from Unlimited to another value...
However, when the insert button is enabled, the error is there regardless of the value of 'Number of values' on the image field.
Comment #12
florisla CreditAttribution: florisla commentedInsert module apparently messes up the 'default image' configuration form for file fields.
With insert module enabled, the "Default image" settings' form elements no longer appear in the file field admin interface.
One of the side effects of the bug is that at
image_field_prepare_view
time,$field['settings']['default_image']
contains the form array and not the actual default_image string as would be expected.This patch to core image field does not fix the bug, but merely works around the issue by checking if
$field['settings']['default_image']
is indeed a string. So it prevents the array_flip() warning to occur.Haven't found the cause of the bug though.
Comment #13
florisla CreditAttribution: florisla commentedI think I have found the cause.
This fixes an 'early abort' return statement in that did not return the array, as (I think) it should.
After changing this, I see:
array_flip()
error is gonePS: Please ignore the patch in #12 above; it is wrong! (value should not be a string, but an integer)
Comment #14
florisla CreditAttribution: florisla commentedPlease apply #13 and check if it works in your case too.
Comment #15
tsvenson CreditAttribution: tsvenson commented@florisla
Confirmed, seems to do the trick. No more warnings, also checked the log and noting in there either.
Great work, seems this module is now working properly for Drupal 7 again.
Comment #16
okokokok CreditAttribution: okokokok commentedWith patch in #13 the warning disappears but there was no "insert" button yet.
Then I tried disabling and re-enabling insert. Nothing yet.
However drush cc all did the trick and the button is there and working!
Thanks!
Comment #17
nadavoid CreditAttribution: nadavoid commentedAfter applying the patch, I still get the warning message, but only on pages that don't have any images in an Insert enabled field. Using Drupal 7 rc2.
Comment #18
nadavoid CreditAttribution: nadavoid commentedupdating status
Comment #19
FiNeX CreditAttribution: FiNeX commentedIsn't this a dup of bug http://drupal.org/node/937100 ?
Comment #20
JohnnyX CreditAttribution: JohnnyX commentedI get the following errors after set "Enabled insert styles" to colorbox...
But I don't know is it a insert or colorbox bug?
I try to use insert with image resize filter and colorbox to show image with original size
Comment #21
Jamie Holly CreditAttribution: Jamie Holly commented#20 I can confirm this and it's in insert. I have been fighting this for a few weeks and thought it was part of core (see http://drupal.org/node/937100). Finally I disabled insert and my problems went away (I don't use colorbox).
Comment #22
JohnnyX CreditAttribution: JohnnyX commentedI use patched insert, image resize filter and colorbox with my D7 test environment and finally it works!
There was a problem with colorbox. A new release fixed my problems. Testet with a new D7 installation...
But I don't use insert module colorbox integration! I use image resize filter to add colorbox feature to resized images. Works fine for me!
Comment #23
marcvangendAs I also mentioned in #937100: Image/file module passing form values to file_load_multiple(): I had this same problem ("Can only flip STRING and INTEGER values!") after installing Insert module on a site that started when D7 was in beta. The problem went away after updating to Drupal 7.0 and re-saving one of the image field settings (http://example.com/admin/structure/types/manage/[contenttype]/fields/[fi...). It's not really an upgrade path but I hope that helps anyone as a workaround.
Comment #24
ebremer CreditAttribution: ebremer commentedApplied #5 and #13. Working nicely now. :-)
Comment #25
ebremer CreditAttribution: ebremer commentedI take that back. I'm getting the error below when create a style in the "Image Styles" area. Also, the preview image of what a image style will do does not work. The problems go away once the Insert module is disabled.
Error reported:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'image_style_generate' was given in menu_execute_active_handler() (line 501 of /www/mysite-7.0/includes/menu.inc).
Comment #26
ebremer CreditAttribution: ebremer commentedI did some more experiments and the errors crop up when I use the private file system. In changing the insert_menu() function to the below seems to be working for me now (with #5 & #13 applied as well). I'm still testing but so far, no errors.
function insert_menu() {
$items = array();
// Generate image derivatives of publicly available files.
// If clean URLs are disabled, image derivatives will always be served
// through the menu system.
// If clean URLs are enabled and the image derivative already exists,
// PHP will be bypassed.
$directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
$items[$directory_path . '/styles/%image_style'] = array(
'title' => 'Generate image style',
'page callback' => 'image_style_deliver',
'page arguments' => array(count(explode('/', $directory_path)) + 1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
// Generate and deliver image derivatives of private files.
// These image derivatives are always delivered through the menu system.
$items['system/files/styles/%image_style'] = array(
'title' => 'Generate image style',
'page callback' => 'image_style_deliver',
'page arguments' => array(3),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
Comment #27
ebremer CreditAttribution: ebremer commentedHere is a patch that combines #5, #13, and my last post on the changes I did to function insert_menu(). I worked all day with it and finished migrating my site from D6-D7. No errors.
Comment #28
bryancasler CreditAttribution: bryancasler commentedconfirmed, #27 works for me
Comment #29
marcvangendLooks good, but I couldn't test the patch myself because the problem has already gone away on my site. One nitpick:
I think this is a mistake, no need for the extra space.
Powered by Dreditor.
Comment #30
enriquesl CreditAttribution: enriquesl commentedI had the same problem ("Can only flip STRING and INTEGER values!") without the module Insert, and without using image field. I was using the theme "Corolla". The problem disappeared just switching to default D7 theme Bartik, and appear when switching again to Corolla (reloading the user page to reproduce the warning).
Comment #31
quicksketchThanks, the only part needed in this patch after these related issues is the
return $element;
line. These other patches address the remaining portions of the patch.#941000: Insert breaks styled images in Drupal 7
#918958: file_directory_path is removed in D7, replaced with file_default_scheme
Comment #33
bryancasler CreditAttribution: bryancasler commentedQuicksketch, I'm still getting this error, but I can't confirm the cause. Was this patch committed to the D7 branch?
Comment #34
rfay#31 was committed January 20, 2011; commit 55cb1a42575552a80e9fe9046305de3b281528b9
There are lots of ways you could get this obscure error from Drupal, so you'll probably have to do some debugging to figure out where you're getting it from.
Comment #35
tsvenson CreditAttribution: tsvenson commented@animelion: Its also very likely it could be another module that causes this. Can you post the complete error message you get as well as let us know what other modules and versions you use with Insert.
Comment #36
rfay@animelion, if you install Commerce Devel I believe it will give you a stack trace when this error occurs. It does not depend on commerce.
Comment #37
bryancasler CreditAttribution: bryancasler commentedrfay, thanks so much. Quick question, how does it differ from your "Fatal" module? I'll report back here when I have something.
Comment #38
rfayFatal is for testing and creating errors. Commerce Devel is for solving errors you got some other way. Fatal was used as an easy way to create errors for Commerce Devel.
Comment #39
revu CreditAttribution: revu commentedI also have run into the same problem but it is with .mp4 file
Error message
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of www...\includes\entity.inc).
Comment #40
leisurman CreditAttribution: leisurman commentedMy array_flip error can from a default image in a cck field that was missing inside the cck field after a d6 to d7 upgrade
https://www.drupal.org/node/1102570#comment-10978037
Comment #41
stellarvisions CreditAttribution: stellarvisions commentedI found this most helpful
https://www.drupal.org/node/2396677