Hello,

I recently upgraded from 4.7 to 5.1. After tweaking a bit to fix some DB errors and warnings, it now works great EXCEPT CAS login for a new user.

When I login with a new user, it gives me following warnings:

* warning: array_keys(): The first argument should be an array in /my/drupal/directory/modules/user/user.module on line 361.
* warning: implode(): Bad arguments. in /my/drupal/directory/modules/user/user.module on line 361.
* 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 portal_role r INNER JOIN portal_permission p ON p.rid = r.rid WHERE r.rid IN () in /my/drupal/directory/includes/database.mysql.inc on line 172.

What should I do?
Thank you!

Comments

metzlerd’s picture

Try turning on auto-register users in the user account settings for Drupal.

I'm in the process of rolling a new release that will fix this.

Or you could download the HEAD version.

See the following issue for more details.

http://drupal.org/node/121837

shino’s picture

The warning comes up when a new user logs in. New user can login, but with warning appearning. I have tried newest HEAD version, since it closes user registration for CAS login. Regardless of user registration preferences, it does this.

Don't know why... I can login as a new user, but I want to get rid of this warning.

Thank you,

metzlerd’s picture

Try one more time, downloading from HEAD. Sorry for the inconvenience, but I forgot that the tarball hadn't built yet when I last sent the message. I really had just commited this code. If that doesn't work report back your cas settings page, especially the settings labeled "user account settings" and I'll look into it further.

Dave

shino’s picture

Thank you for working with me. I have updated the file to latest one that reads following:
--------------------------------------------------------------------------------
Revision 1.15 - (view) (download) (annotate) - [select for diffs]
Fri Mar 2 20:35:55 2007 UTC (2 days, 23 hours ago) by metzlerd
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +39 -2 lines
Diff to previous 1.14
Added CAS suggested menu item.
--------------------------------------------------------------------------------

Here is my cas settings
CAS Server settings================
* CAS Version: 2.0
* CAS Server: case server URL without http://
* CAS Port: 443
* CAS URI: /cas
* Is Drupal also the CAS user repository? - not checked
* If CAS is not the user repository, should cas highjack users witht the same name? - tried both but warning was still there for new user login, but currently not checked.
* Should Drupal user accounts be automatically created - checked
* Email Domain - I have set email domain to appropriate one
* User canot change email address - checked
* User canot change password - checked

Redirection settings================
* specific pages - checked

LDAP settings settings================
* not checked since I tried to use extract the user email from and LDAP directory and didn't work for me.

I still get an error message when I login as a new user.

Thank you for all your help.

metzlerd’s picture

Ok, looked at the code and the error some more and am more confused than ever.

Oddly the code that's throwing the error is in the function that tests permissions. it would seem to imply that there are no roles assigned to the user, which is odd. I've scoured my code to find a place where roles are missing in the user account creation, but can't find any.

I noticed that you're working on a multisite install, that is, you've got tables that are prefixed with portal. I'm starting to suspect that the bug is related to that. Is there any way that you can confirm this in your environment? Do you have any non-multisite installs that you can test against?

I'm getting stumped and I can't reproduce the problem.

Any info you can give me about your multisite configuration would be helpful.

Likely I'll have to try and duplicate your multisite install or give you custom debugging code to get to the bottom of this.

deelight’s picture

Have you tryied destroying the previously created account after the upgrading to the HEAD version ? I'm not sure about it, but the previous version may have created a buggy user account. I had exactly the same error, and the HEAD version solved it.

shino’s picture

@metzlerd

I am puzzled as well. I have been troubleshooting this issue for sometime trying to figure out why it is trying to grab a role at the time of a new user creation. I have an instance that running 4.7 separate from what I'm working on. I'll upgrade it to 5.1 and see if gives same warnings for CAS. Currently it produces warnings for all the multi sites when a new user login.

@deelight

I've cleared all the users on one instance and tried to login in with it, but I still got an error.

@metzlerd & deelight
Do you think there were errors during the upgrade from 4.7 to 5.1 that caused this?

shino’s picture

Result of testing upgrade from 4.7 to 5.1 in single instance drupal showed that cas login did not give any warning. I'll lookinto code more carefuly having multi site issues in mind.

Thank you!

driki_’s picture

Hello,

I have the same problem,
but no multisite install, and i'am not upgrading from a 4.7.

metzlerd’s picture

drico,

Could you let me know what version you're using? 5-x or Head, and what your cas settings are? Have you configured user account settings to allow user accounts to be created automatically?

We're trying to narrow this down, but need more info. I'd also like to know from any who are experiencing this problem, what PHP version you're running and whether clean url's are enabled or no.

shino’s picture

I do have clean URL enabled and I'm using PHP 4.3.9 & mysql Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i386) using readline 4.3 (I got this from mysql status command)

Thank you!

deelight’s picture

Do you use the Profile module ?

I may be wrong, but I had exactly the same problem today after activating the Profile module - I still haven't had time to try to understand why.

shino’s picture

Good catch! You are right. I disabled profile modules and warning messages are gone!!!! Now, why is that... I'll take a look at this issue also, because I'm sure more than I want to have profile module turned on while sigining in with CAS...

metzlerd’s picture

Likewise, with a reproducible path, I'm sure between the three of us we'll find the bug and squash it! I'll try and work on this tonight.

metzlerd’s picture

Status: Active » Fixed

Got it. The insert hook for for profile.module does some permissions check that were causing a problem because the $user object wasn't done loading. Because these things require administrative permission to perform, I've added some code that will make Cas become the admin user (user 1) for the duration of user_save event. This solved the problem.

I've applied a fix to HEAD that will solve this problem.

Anonymous’s picture

Status: Fixed » Closed (fixed)
danepowell’s picture

Version: 5.x-1.0 » 6.x-2.0
Status: Closed (fixed) » Active

Sorry to reopen a dreadfully old issue, but this problem seems to have cropped up again. I am seeing this in 6.x-2.0, with Profile and Content Profile enabled (if that's important). The errors are basically only different in line numbers I believe:

array_fill() [<a href='function.array-fill'>function.array-fill</a>]: Number of elements must be positive in /var/www/drupal/core6/includes/database.inc on line 253.

implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in /var/www/drupal/core6/includes/database.inc on line 253.

array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /var/www/drupal/core6/modules/user/user.module on line 502.

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 &#039;)&#039; at line 1 query: SELECT p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/core6/modules/user/user.module on line 502.

danepowell’s picture

The error in user.module is part of the user_access function, if that helps. I can't really help debug this because I do not administrate our CAS server and thus can't log in as anyone other than myself.

metzlerd’s picture

I've enabled the profile module and not been able to reproduce the error. I guess that leaves us stumped. Perhaps you could let me know more about your user account settings? The code that fixed this document case is still in place and appears to be functioning. You might consider adjusting the module weight of content profile, but I'm really at a loss as to what could be causing this.

danepowell’s picture

This is also accompanied by four instances of the following warning in my PHP error log:
[error] [client 10.66.57.149] PHP Notice: Trying to get property of non-object in /var/www/drupal/core6/modules/dblog/dblog.module on line 138, referer: https://cas-server.example.com:443/....

A couple things that you might note - although the error is the same as the OP, the line numbers in database.inc and user.module are different. If you think this might be a different issue, we can open a new one. Also, I am using Content Profile in addition to Profile. If you need me to figure out what other modules on my site implement hook_user I can try to find out.

BTW, I know this is a somewhat non-specific error, but I'm certain that it's at least aggravated by CAS, since normal user account creation doesn't cause problems. I appreciate your help.

metzlerd’s picture

Status: Active » Closed (fixed)

Lets start a new issue on this since, i'm pretty sure the fix on this one is still functional. This seems like it must be a different issue. In the issue be sure and document all of your User Account Settings. I think this one might be related to default roles, since that's the part of the query that's blowing up.

Dave