warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /sites/all/modules/role_expire/role_expire.module on line 297.

Hello,

I am getting the above error message when creating a new user via Rules, without using Role Expire module at all.

I have not defined any default expiration values, perhaps that is the issue.

I have not yet found why exactly, but I thought it is better to report it, perhaps others see this as well.

Comments

stewsnooze’s picture

Status: Active » Postponed (maintainer needs more info)

What URL are you on in Rules and what steps do you take to get it? For instance have you created a specific rule to create a user?

giorgio79’s picture

Yes, I created a rule, that creates a user in certain cases (here is the module that does it http://www.drupal.org/project/clickbank_ipn)

This happens after the rule is executed and the user is created fine.

The user is created as expected.

eg208’s picture

Version: 6.x-1.9 » 6.x-1.12

I am getting this error too when create account using facebook oauth http://drupal.org/project/fboauth

warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/xxx/public_html/sites/all/modules/role_expire/role_expire.module on line 383.

stewsnooze’s picture

This should be raised in its own issue. It shouldn't be out on the end of this one. Also you really should try this action without the other module turned on before you add the issue as even though the error appears to be in role expire it could be the other module wrecking the data before role expire gets it

travisjbennett’s picture

Status: Postponed (maintainer needs more info) » Needs review

Good to know I'm not alone!
My error message was a bit different due to my use of a newer version of PHP: "warning: array_key_exists() expects parameter 2 to be array, null given in
/(...)/www/sites/all/modules/role_expire/role_expire.module
on line 303.
(Shown 8 times)

I can confirm this is a bug whenever programmatically creating users, especially without roles right-off-the-bat.
My fix is below, to just replace null with an empty array via an if / elseif statement.

I don't know how to role a patch, and don't use Drupal 7 much, so my solution is all I can provide. Can I get a reviewer?

Drupal 6: Starting around line 301 of role_expire.module,v 1.22 2010/06/20 20:47:16

if ($op == 'insert') {
              // Check for Role
		// CUSTOM IF FOLLOWS
              if (is_null($edit['roles'])) {
                $foo_roles = array();
              } else {
                $foo_roles = $edit['roles'];
              }
              // END CUSTOM
              if (array_key_exists($rid, $foo_roles) && $edit['roles'][$rid] == $rid) { // CUSTOM: Replaced $edit['roles'] with $foo_roles here.
                role_expire_process_default_role_duration_for_user($rid, $account->uid);
              }

Thanks!

rcodina’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Drupal 6 version is unsupported!