Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 167 of /www/drupal-7.0-beta1/includes/entity.inc).

/www/drupal-7.0-beta1 is where I install my instance of Drupal 7.0 Beta 1. I get the above error message when trying to add a image field to my basic page content type.

CommentFileSizeAuthor
#4 flipstringerror.jpg47.97 KBrobhamm
#2 bug1.jpg294.71 KBebremer
#2 bug2.jpg329 KBebremer
#2 bug3.jpg419.75 KBebremer

Comments

furamag’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide the screenshot of error page. I have added image field to page content type without any errors.

ebremer’s picture

StatusFileSize
new419.75 KB
new329 KB
new294.71 KB

Attached
bug1.jpg - what it looks like looking at a sample about page
bug2.jpg - what i added
bug3.jpg - click save and error starts showing. Removing the field clears the error.

Shiny’s picture

Version: 7.0-beta1 » 7.0-beta3

still happening in beta3
Error message
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 167 of /home/brenda/projects/drupal/seven/includes/entity.inc).

robhamm’s picture

StatusFileSize
new47.97 KB

This doesn't seem to be just an image issue. Another way to reproduce is to go to your "my account" page, then click on a "home" link. Screen shot attached.

* Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 167 of /home/robhamm/public_html/main/includes/entity.inc).
* Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 343 of /home/robhamm/public_html/main/includes/entity.inc).

ebremer’s picture

Status: Postponed (maintainer needs more info) » Active
juves’s picture

Version: 7.0-rc1 » 7.0-beta3
Component: other » image system

I recive this Warning if I go to 'My Account' and then reload this page or go anywhere else
I recive this Warning immediately, if i go to 'user/username/edit'

RC1

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (Line 178 www/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (Line 354  www/includes/entity.inc).
juves’s picture

Version: 7.0-beta3 » 7.0-rc1
Component: image system » other
amirtaiar’s picture

Version: 7.0-beta3 » 7.0-rc1
Component: image system » other

I am getting the same error - what is that and what can I do?

Jamie Holly’s picture

Version: 7.0-rc1 » 7.0-rc2
Priority: Normal » Major

I can confirm this issue. What's happening is file_load_multiple() is getting passed $fids. Each item in $fids actually contains an array:

Array
(
    [0] => Array
        (
            [fid] => 0
            [upload_button] => Upload
            [remove_button] => Remove
            [upload] => 
        )

)

That is then passed eventually to DrupalEntityControllerInterface->load, which is where the error occurs.

The temp (and ugly) fix I put in right now was to extract the $fids into a new array in file_load_multiple():

function file_load_multiple($fids = array(), $conditions = array()) {
  // Start temp fix for 937100
  if (is_array($fids[0])){
    $fFids=array();
    foreach ($fids as $data){
      $fFids[]=$data['fid'];
    }
  } else {
    $fFids=$fids;
  }

  //End temp fix


  return entity_load('file', $fFids, $conditions);
}

I've bumped the priority to major given the popularity of file fields and can confirm it also exists in RC2. Not sure if my fix is the best route for it. I just don't know that much about the new fields engine in D7. I just traced back far enough to get a temp fix in. Not really sure if this is an issue in the file system or image.

**Edit - I just noticed that this only occurs if there is no image selected. If you have an image then this is not called. It doesn't depend on the required checkbox.

ebremer’s picture

This seems to be working for me now in RC3.

nihonsei’s picture

Version: 7.0-rc2 » 7.0-rc3

In Drupal 7.0 - rc3, getting this warning.

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of includes/entity.inc).

droplet’s picture

What system os, php version.

seems to be ok in Dev. version.

nihonsei’s picture

Getting above warning after log in to site (Just after "Session opened for admin").
OS: Linux; PHP: 5.2.14
My site (http://indojp.com) is hosted on Bluehost.com.

ddorian’s picture

Version: 7.0-rc3 » 7.x-dev
Status: Active » Postponed (maintainer needs more info)

please check with latest dev
droplet says no errors in latest dev
set to active if error still shows in the latest dev

Jamie Holly’s picture

Status: Postponed (maintainer needs more info) » Active

Still getting the error:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of E:\HIT\devel\hit\hit\includes\entity.inc).

This is on PHP 5.2.14 and still occurs if you have an image field with no image. As soon as you add an image it goes away.

catch’s picture

Title: Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() » Image/file module passing form values to file_load_multiple()
Component: other » file.module

Moving to file module for now.

ebremer’s picture

For reasons of testing, I removed the one image I had and the problem returned even in RC3. However, like #15 intoxination, the error goes away once you add an image.

Jamie Holly’s picture

Digging further into this, here's what I am finding. In image_field_prepare_view(), it attempts to load the default image:

    if (empty($items[$id]) && $field['settings']['default_image']) {
      if ($file = file_load($field['settings']['default_image'])) {
        $items[$id][0] = (array) $file + array(
          'is_default' => TRUE,
          'alt' => '',
          'title' => '',
        );
      }
    }

file_load() should take an array of fids, but this is what's being passed to it:

Array
(
    [fid] => 0
    [upload_button] => Upload
    [remove_button] => Remove
    [upload] => 
)

The error also pops up on the image field settings page and is from image_field_settings_form():

  $form['default_image'] = array(
    '#title' => t('Default image'),
    '#type' => 'managed_file',
    '#description' => t('If no image is uploaded, this image will be shown on display.'),
    '#default_value' => $field['settings']['default_image'],
    '#upload_location' => 'public://default_images/',
  );

I don't even get the default image settings to show on the page, so something appears to be going on in managed_file.

Jamie Holly’s picture

OK I dug deeper. I did a new install from head and everything works fine. I then checked on a site that was built starting with RC2 and the problem persists, so the problem appears to be fixed, but if you are upgrading it still exists. Perhaps we need an upgrade path to roll in the fix?

nihonsei’s picture

I also did a new install (7.x-Dev), but getting same warning twice at the time of login.

R2-D8’s picture

After testing some 7.x-modules i went flushing all caches;
afterwards i wanted to set the site back online on the maintenance page.
There i got those errors:

    * Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (Zeile 178 von /var/www/SOMEFOLDER/httpdocs/drupal-7.x-dev/includes/entity.inc).
    * Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (Zeile 354 von /var/www/SOMEFOLDER/httpdocs/drupal-7.x-dev/includes/entity.inc).

After refreshing the page the error was gone.

UPDATE

On the imce-tab at the user screen ( user/1/imce ) those errors persist.

Greg Adams’s picture

OK I'm having the same problem on a new install of drupal 7.0.
I am getting errors here and there. (too many for my taste)

(Little OFF TOPIC)
I installed TAO and Rubik theme (needed to modify Rubik to work correctly).
Funny thing is.. I got an error after I uploaded the SKY theme (not even activated) so I deleted that immediately. (those were different errors than this one)

I guess Drupal 7 and it's modules/themes are not really ready for public as it is supposed to.
NO OFENCE...(I know how hard people worked on this) but this is definitely not making my work easier.
What I normally do in about 3-4 hours has taken me 2 days (2 days like in 30 hours - 2 days) so far and was all for nothing.

Just saying that it might have been a little early for a drupal 7 release.
I will be working with Drupal 6.20 on the next few websites I'll be making.

What I found out:
The problem occurs when I install the "Page-Title" module.

finex’s picture

I confirm that the problem occurs after enabling "page title" module. (using Drupal 7.0)

ebremer’s picture

another problem. I created a new node type, but this time, I made the image field use a private download. The above problem still occurs, goes away when you actually upload an image, but then a new error is added on saving of the node:

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/drupal-7.0/includes/menu.inc).

It goes away if I remove the uploaded cck image, but, then the original error comes back. - E

PS - This being on Drupal 7.0

marcvangend’s picture

Re #19: I believe you're right, I had the same problem on a site that started with a beta version. The error was reported three times on my home page: once for every file or image field. 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.

ecksley’s picture

Disabling Page Title module (on D7) fixed this problem for me as well. Thanks for the tip.

gc11’s picture

Disabling the Page Title module has fixed most of the error messages i had been receiving, including when setting up test users. Thanks for that.

ebremer’s picture

I just did a fresh install of Drupal 7.0 and the problem still persists.

I get this error now when I enter the "Image styles" area (I have two custom image styles created):

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/ebremer-7.0/includes/menu.inc).
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/ebremer-7.0/includes/menu.inc).

catch’s picture

Are you sure that was a fresh install with a clean database? image_style_generate() doesn't exist as a function in Drupal 7 any more, and is only mentioned in a code comment. If it's a new install, do you have contributed modules installed?

I can't reproduce this locally, but I did get these errors on http://d7.7/node#overlay=admin/config/media/image-styles/edit/thumbnail


    * Warning: Division by zero in theme_image_style_preview() (line 787 of /home/catch/www/7/modules/image/image.admin.inc).
    * Warning: array_intersect_key(): Argument #1 is not an array in theme_image_style_preview() (line 789 of /home/catch/www/7/modules/image/image.admin.inc).
    * Warning: Division by zero in theme_image_style_preview() (line 787 of /home/catch/www/7/modules/image/image.admin.inc).
    * Warning: array_intersect_key(): Argument #1 is not an array in theme_image_style_preview() (line 789 of /home/catch/www/7/modules/image/image.admin.inc).

So we're definitely missing some test coverage.

Jamie Holly’s picture

I finally tracked down what was causing the issue on my side to being an issue with the insert module. See:

http://drupal.org/node/850946

ebremer’s picture

Yes, a clean database, and I think intoxination may have found it. I did turn on insert after the db wipe. My bad. The problem persists though even after the insert module is removed. But it does disappear when you delete the previously "Insert" enabled fields then re-add them.

Jamie Holly’s picture

Actually you don't need to delete the fields, just go to the screen for each field and resave them. It appears it's something with information the insert module is saving into the field info.

I'm just wondering if there aren't other modules that could also be causing this problem for other people. Perhaps there was an API change in the field stuff along the lines and the contrib modules aren't caught up yet.

catch’s picture

AbdullahR’s picture

page_title model show me this error when I move from user profile to home page through site logo

lammertsm’s picture

Page Title 7.x-2.4-beta1 Module causing the issue on my site.

* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /includes/entity.inc).
* Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of /includes/entity.inc).

dave reid’s picture

@AbdullahR @lammertsm: Then go to the page_title issue queue! This was already fixed with #1018280: Warning: array_flip() entity.inc in page_title.

mrgoltra’s picture

sub. Trying to figure this one out.

Dabitch’s picture

Sub. Getting "Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178" with any version of token (patched, not patched, old patched, latest dev) now hunting elsewhere. Testing on an 6.20 -> D7 upgrade.

bhorsa’s picture

sub. getting the error when I log in with a test account to create content. Only appears when first moving away from home page after log-in. Does not reappear until re authentication.

francisrmd’s picture

Disabling Image module cleared this problem for me in Drupal 7.x.

SchwebDesign’s picture

subscribing. Here's what my error looks like:

"Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /var/www/html/JOSHUA/drupal/includes/entity.inc)."

I believe the first time i got this was after installing the video module and adding an image and video field to the same content type.

spessex’s picture

Disabling Page Title module (on D7) fixed this problem for me as well.

zincdesign’s picture

Disabling Page Title module has fixed the problem for me.

shortspoken’s picture

#42 solved the problem for me. Had a video and image field at the same content type. Deleted the video field and the error message was gone...

rade’s picture

I got the same error when trying to use file_load_multiple() in my own module.
The problem occurred when I used field_get_items() to fetch all items of a certain field in a node and then pass the value of that as entity IDs to file_load_multiple().

My original code, which caused the error:

  $items = field_get_items('node', $node, 'field_media');
  $files = file_load_multiple($items);

This is what array $items looks like now:

Array
(
    [0] => Array
        (
            [fid] => 12
        )
 
    [1] => Array
        (
            [fid] => 54
        )
 
    [2] => Array
        (
            [fid] => 55
        )
 
    [3] => Array
        (
            [fid] => 72
        )
 
)

The fix was to store only the IDs in a new array:

  $items = field_get_items('node', $node, 'field_media');
  foreach ($items as $item) {
    $ids[] = $item['fid'];
  }
  $files = file_load_multiple($ids);

Now the array $ids looks like this:

Array
(
    [0] => 12
    [1] => 54
    [2] => 55
    [3] => 72
)

Hope this helps!

//Rade

sayansk’s picture

I think that is very close to solving the mystery ... Maybe someone have a specific solution?

adamgerthel’s picture

I've got this error on a D7.7 install on an image field on a term. The message appears when trying to add a new term.

bmango’s picture

I started getting this error message when I included a default picture for user profiles and then created a view of new users with their photo. I configured the view as a block, and any pages which showed this view got the error message. Removing the photo from the view fixed the problem, and the error message disappeared.

jwilson3’s picture

I started getting this error when I made a call to taxonomy_term_load_multiple($items) in a custom module.
The list of $items being passed in has the following structure:

Array(
    [0] => Array(
        [tid] => 1
    )
    [1] => Array(
        [tid] => 3
    )
)

Notably, in this case, even though the warning message is thrown, the function call itself does return a valid list of fully loaded taxonomy terms.

So two things:
1) this issue is not limited to image/file modules only, but rather a deeper core bug with the *_load_multiple() not properly handling the variety of input that implementing modules could be using.
2) something is inconsistent in that implementing module (taxonomy in this case) works fine with array of arrays type structures, but the entity module/controller/whatever does not.

drecute’s picture

I'm getting this error in hook_block_configure of a custom module. I'm providing a form for managed_file upload and this error pops up just when the #element_validate callback is called.

function uec_core_block_configure($delta = '') {

  $form = array();
	switch($delta) {
		case 'uec_core_request_prospectus':	
			$form['uec_request_prospectus_block_image'] = array(
				'#type' => 'managed_file',
				'#title' => t('Image'),
				'#description' => t('Upload an image for request prospectus block, allowed extensions: jpg, jpeg, png, gif'),
				'#default_value' => variable_get('uec_request_prospectus_block_image',  ''),
				'#element_validate' => array('uec_request_prospectus_block_image_validate'),
				'#upload_location' => 'public://' 
			);
			
			$form['uec_request_prospectus_block_image_style_name'] = array(
				'#title' => t('Image style'),
				'#type' => 'select',
				'#description' => t('Choose an image style to use when displaying this image.'),
				'#options' => image_style_options(TRUE),
				'#default_value' => variable_get('uec_request_prospectus_block_image_style_name', ''),
			);
	}
	return $form;
}

function uec_request_prospectus_block_image_validate($form, &$form_state) {
	$file = file_save_upload('uec_request_prospectus_block_image', array(
    'file_validate_is_image' => array(), // Validates file is really an image.
    'file_validate_extensions' => array('png gif jpg jpeg'), // Validate extensions.
  ));
  // If the file passed validation:
  if ($file) {
    // Move the file, into the Drupal file system
    if ($file = file_move($file, 'public://')) {
      // Save the file for use in the submit handler.
      $form_state['storage']['uec_request_prospectus_block_image'] = $file;
			// put the file in variable_set for use in submit handler and hook_block_view
			//variable_set('uec_request_prospectus_block_image', $form_state['storage']['uec_request_prospectus_block_image']);
    }
    else {
      form_set_error('uec_request_prospectus_block_image', t('Failed to write the uploaded file the site\'s file folder.'));
    }
  }
  else {
    form_set_error('uec_request_prospectus_block_image', t('No file was uploaded.'));
  }
}

This thread at SO makes a case for all *_load overrides.

In my implementation, I do not have a reference of *_load but I'm sure the error started at the call of uec_request_prospectus_block_image_validate. Also not sure if file_save_upload() could be the cause.

Pimmy’s picture

I get this error with D7.9 when a result from a search is returned and only when logged in as authenticated user.

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /var/www/htdocs/includes/entity.inc).
IronWorker’s picture