The site admin doesn't see this error. It comes up for anonymous and authenticated users on the Ubercart checkout screen:

warning: key_exists() [function.key-exists]: The second argument should be either an array or an object in /home/content/b/r/o/brooklynnet/html/musictutor/sites/all/modules/user_badges/user_badges.module on line 272.

Using Drupal 6.24, Ubercart 6.x-2.7

CommentFileSizeAuthor
#2 roles_error_test-1463102.patch508 bytesao5357
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ryank76’s picture

Still getting this error, does anyone have any help or ideas?

ao5357’s picture

FileSize
508 bytes

Attached is a patch file to apply a test for your particular condition. It checks to see if the $roles variable is an array. If it isn't, it sets it as an empty array. Please reply as to whether this makes the error go away or not.

This patch is a one-line change, so you could just paste:

$roles = (gettype($roles) === "array") ? $roles : array();

right below line 263 in user_badges.module

ryank76’s picture

Hi, thanks for posting the patch. Unfortunately the error is still the same.

ryank76’s picture

I've updated to the latest dev version, still getting the error. Also tested the patch above, still getting the error.

ao5357’s picture

I think this is related to the unfixed error #964546: $account->badges_all issue.

Since setting $roles to an array doesn't make the error go away, that means $account->badges_all is the likely culprit.

A temporary fix would be:

if (key_exists($rid, $roles) && (!is_array($account->badges_all) || !key_exists($roles[$rid], $account->badges_all))) {

…but the real solution would be to get the previously mentioned error fixed throughout the module.

Simon Georges’s picture

Status: Active » Needs work

Changing status, as there is a patch.

shabana.navas’s picture

Status: Needs work » Fixed

Please upgrade to the latest dev version and re-open the issue if you are still getting the problem.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.