Download & Extend

Warning: array_flip() entity.inc

Project:Page Title
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I get the folowing error on user/1/edit page:

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

(* = username)

Drupal 7.0 minimal install, only alpha1 or later on enabled modules.

Comments

#1

Status:active» postponed (maintainer needs more info)

*what* enabled modules?

This usually indicates that a module is calling user_load() in a wrong way, for example user_load(array('uid' => 1)), which is not supported anymore in D7.

#2

Ahh sorry. The modules I have enabled are:

  • IMCE
  • IMCE Mkdir
  • Local updater
  • Page Title
  • Password toggle
  • Pathauto
  • Redirect
  • Token
  • Taxonomy Manager
  • CKEditor
  • External Links

I also have some core modules installed, but I don't think that could be the problem.

#3

Try to either disable each of those modules one by one and see if the error still happens once you figure out which module is responsible.

Then move this issue to the issue queue of that module

You can also search for "user_load(array" in sites/all/modules, might be faster if you have a tool that can search recursive through directories.

#4

I got it. It's the Page Title 7.x-2.4-beta1 module that caused it. I'll try to look in the Page Title issue then

#5

Project:Drupal core» Page Title
Version:7.x-dev» 7.x-2.x-dev
Component:base system» Code
Status:postponed (maintainer needs more info)» active

Moving the issue.

#6

Line 29 and 34 of path_title/modules/user.page_title.inc is causing this

It calls "user_load" with an array as the first parameter instead of just the uid

Line 29:

Currently: $types['user'] = user_load(array('uid' => arg(1)));
Should be: $types['user'] = user_load(arg(1));

Line 34:

Currently:  $types['user'] = user_load(array('uid' => arg(1)));
Should be: $types['user'] = user_load(arg(1));

Actually, can we not optimise this code and first check if a pattern was defined for the user (a variable get is much faster than a user_load), so the idea is that we only set "$types" if "$pattern != empty string". I'm asking because I'm not sure how "$types" is used in the rest of the code.

PS: Sorry I don't have my "patching enviroment" set up at the moment - moved to a new pc. Will submit a patch soon so that this can work with drush make's patching system.

#7

Status:active» needs review

Patch attached :)

I also see there are tests for taxonomy and all sorts of things, but not a test for the user page. Once I've gone through a few "how to write simpletests for drupal" tutorials I'll try to tackle that as well.

AttachmentSize
page_title_issue_101820_user_array_flip_warning.patch 958 bytes

#8

Status:needs review» reviewed & tested by the community

Haven't tested it, but the patch is correct and simple.

#9

@nightowl77 patch works, thanks for the quick fix!

#10

The patch worked perfect.

#11

May I ask when this patch will find its way into the 'Page Title' module? The current versions (2010-Nov-02) of it are quite old. In addition to that, other Drupalistas seem to suffer from this bug as well, see #1019936: Problem with array_flip() .

Thanks for the module! It is great.

#12

The patch worked thanks.

#13

Status:reviewed & tested by the community» closed (fixed)

Thanks guys - committed to dev. Will be in the next main release.

#14

I am very new to Drupal.. how do I apply this patch?

#15

@spunge: Instead of applying the patch, you are well advised to take the most current dev version of this module!

#16

Ok. Do I remove the current version of the module first or do I just overwrite and replace it with the current dev version?

#17

... replace it -- unless the instructions are otherwise (usually when there is no upgrade path).

nobody click here