Error on new user account submission

karinab1 - July 23, 2009 - 22:26
Project:Role Weights
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I am using Path Access to restrict only authorized users to my site. After upgrading my Drupal install and updating the modules, I get this error after a user signs up for an account:

warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/leadersf/public_html/modules/role_weights/role_weights.module on line 274.

The same error occurs 6 times on the page .... the user account is created. I don't actually have anything enabled in the settings for Role Weights. I just have it because Path Access depends on it.

Any suggestions on fixing the error?

#1

leafish_paul - August 10, 2009 - 15:32
Status:active» needs review

Looks like when path_access module enabled, the function path_access_init() at line 35:

<?php
  $role
= module_exists('role_weights') ? module_invoke('role_weights', 'get_highest', $user->roles) : array('name' => $user->roles[1]);
?>

is called at page load. If the user is registering $user->roles is empty/null. Can you try the attached patch to see if it rectifies the errors? Basically, if the $roles variable passed to role weights is empty, we don't need to check roles or return any values.

AttachmentSize
role_weights_529216-1.patch 719 bytes

#2

bsuttis - September 21, 2009 - 21:59

Just wanted to say that the patch fixed the issue for me, thanks much.

#3

leafish_paul - November 4, 2009 - 12:51
Version:5.x-1.5» 5.x-1.x-dev
 
 

Drupal is a registered trademark of Dries Buytaert.