When a user registers on our site, they are getting this error:

warning: array_keys(): The first argument should be an array in /home/election/public_html/modules/user.module on line 348. 
warning: implode(): Bad arguments. in /home/election/public_html/modules/user.module on line 348. 
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT DISTINCT(p.perm) FROM main_role r INNER JOIN main_permission p ON p.rid = r.rid WHERE r.rid IN () in /home/election/public_html/includes/database.mysql.inc on line 120. 

I did some searching on this site, but everything I could find talked about the privatemessage module. We do not have that one installed.

Any idea what's causing this? I've made no changes to the user.module.

CommentFileSizeAuthor
#2 user.module_r1.612.2.11_patch01780 bytesAjK
#1 user.module_r1.632_patch01765 bytesAjK

Comments

AjK’s picture

Status: Active » Needs review
StatusFileSize
new765 bytes

Patch attached that fixes this.

best regards,
--AjK

AjK’s picture

StatusFileSize
new780 bytes

And a DRUPAL-4-7 version of the patch as the previous one (for cvs version) didn't apply

best regards,
--AjK

killes@www.drop.org’s picture

I think we need to ensure that the roles array has at least one element for the query to not throw an error. Also, I'd like to know why we get the error at all, ie I'd like to see it fixed where it occurs.

AjK’s picture

Status: Needs review » Active

killes, fair point. I've had a look at the code and really can't see why $account->roles would become unset. In fact, the code between DRUPAL-4-7 and HEAD appears the same. So, the problem I have is I cannot reproduce jsimonis's problem as described.

I can only assume that another module is clobbering it somehow. But, without jsimonis's setup, then all I can offer is that jsimonis use the patches to protect against the error occuring. And that means they obviously shouldn't be applied to cvs (as you pointed out).

So, jsimonis, if you want a proper fix, you'll need to supply more info (like what modules you have installed) so that I and others can reproduce your problem.

best regards
--AjK

jsimonis’s picture

I played with it all night and finally figured it out. It's the cpanel module that's making the errors pop up.

AjK’s picture

Project: Drupal core » Cpanel Integration
Version: 4.7.0 » 4.7.x-1.x-dev
Component: user.module » Code
floydk’s picture

does this patch just need to be added to the end of the users.module file? or is there a certain area for it - sorry if the question is dumb, I'm a newbie.

yecarrillo’s picture

I'm trying to catch the code causing this error.

I just can see that consecutive calls to $account = user_load(array('uid' => $user->uid, 'status' => 1)); may be causing this problem.
Another thing is that I buld a form outside of $type selection. This means calling this routine on every call of cpanel_user hook.

Please somebody with 4.7 API experience can review my code of user hook to find other strange things.

ekul08’s picture

Thanks for this patch! Works a beauty!

To install this patch: first make 2 copies of user.module (one for a backup, one to edit)

Oped the one to edit. Hit Ctrl + F and find the line where it says

"if (!isset($perm[$account->uid])) {"

then, delete that line, and the two line's under it (the one that starts with @result =, and the one that starts with $perm) then replace it with the following lines of code:

if (!isset($perm[$account->uid]) && is_array($account->roles)) {
     $result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys($account->roles)));
 
     $perm[$account->uid] = '';
Transformis’s picture

Yes!

Wonderful work with that patch. Thank you!

AjK’s picture

I'd like to point out to those using this patch that all it does is make the user interface related problem "disappear". As killes pointed out above, it doesn't fix/cure the underlying problem.

clubsparkle’s picture

I am having similar issues, has this been fixed?

AjK’s picture

Status: Active » Closed (fixed)

Last commit to project May 26, 2006. Dead project and issue queue?