A custom authentication module I wrote for our organization works in 4.7 but causes 5.0 to display a red error box above the starting page content. The error only appears when the user doesn't already exist and has to be created by Drupal. Subsequent logins, and page refreshes do not generate the error message.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/httpd/vhosts/community.viedu.org/drupal-5.0-rc1/modules/user/user.module on line 358.
* warning: implode() [function.implode]: Bad arguments. in /var/httpd/vhosts/community.viedu.org/drupal-5.0-rc1/modules/user/user.module on line 358.
* 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 communityrole r INNER JOIN communitypermission p ON p.rid = r.rid WHERE r.rid IN () in /var/httpd/vhosts/community.viedu.org/drupal-5.0-rc1/includes/database.mysql.inc on line 167.
Above line 358 in the user.module changing this if:
// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
if (!isset($perm[$account->uid])) {
to
// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
if (!isset($perm[$account->uid]) && is_array($account->roles) ) {
Stops the error message, but is probably just covering up a different problem. :)
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | dummyauth.tar.gz | 403 bytes | twibberjix |
Comments
Comment #1
RobRoy commented$account->roles should always be an array. Sounds like your module may be messing with the user object and setting roles to a scalar?
Comment #2
twibberjix commentedNone of my debugging of the module has revealed anything wrong with the user object at various points inside it. Since I have the time I'm currently trying to pinpoint when the error is occurring exactly. The order of the log messages is "PHP error", "new external user created", "session opened" so I'm focusing on what's going on right before the the new account is created.
Is there anything about the external auth process that changed from 4.7 to 5?
Comment #3
twibberjix commentedAfter taking the user.module from 4.7.4 and replacing module_exit() with module_exists() and inserting the user_login_block() function from version 5 - I was able to "New external user: nate@launchpad using module launchpad." without having any errors preceding it.
I will continue searching for what's causing the error messages in version 5.
Comment #4
twibberjix commentedJust to clarify - that previous message meant that I was replacing the user.module that ships with 5rc1 with the user.module that ships with 4.7.4.
Comment #5
twibberjix commentedAha!
I appended debug_print_backtrace() to the messages watchdog was recording and discovered that the problem appears to come from the Profile, and the Category access control lite modules. The respective traces follow.
Without either of those turned on the problem does not occur. Not sure what to do from here, so I will wait. :)
Comment #6
RobRoy commentedDisable any contrib modules (cac_lite) and see if there is a problem with profile module. If not, move this issue to cac_lite.
Comment #7
twibberjix commentedIt happens when either one is enabled, and when both are enabled. I didn't provide the backtrace for when both were enabled because it was basically a combination of the other two backtraces.
Comment #8
RobRoy commentedCan you test this on 5.x-dev to see if the problem has been fixed in the development snapshot?
Comment #9
twibberjix commentedTried it with CVS checkout this morning and the problem is still there, here's the backtrace:
I did not try the CAC lite module.
Comment #10
twibberjix commentedHere's some more debugging info created from adding print_r($user) to the beginning of some profile.module functions and user_access from user.module. I'm still trying to figure out how this is happening, it looks like $user is lost somewhere between the profile_save_profile and _profile_get_fields calls ?????
print_r($user) from inside user_access($string="administer users", $account=):stdClass Object ( [uid] => 0 [hostname] => 69.105.92.2 [roles] => Array ( [1] => anonymous user ) [session] => ) print_r($user) from inside user_access($string="administer access control", $account=):stdClass Object ( [uid] => 0 [hostname] => 69.105.92.2 [roles] => Array ( [1] => anonymous user ) [session] => ) print_r($user) from inside user_access($string="access user profiles", $account=):stdClass Object ( [uid] => 0 [hostname] => 69.105.92.2 [roles] => Array ( [1] => anonymous user ) [session] => ) print_r($user) from inside profile_save_profile($edit=Array,$user=Object id #2,$category=account)::stdClass Object ( [uid] => 13 [name] => nate@launchpad [pass] => 3858eb8d14d29c9654280d365734e08e [mail] => nate@viedu.org [mode] => 0 [sort] => 0 [threshold] => 0 [theme] => [signature] => [created] => 1168629939 [access] => 0 [login] => 0 [status] => 1 [timezone] => [language] => [picture] => [init] => nate@launchpad [data] => [roles] => Array ( [2] => authenticated user ) [launchpad] => Array ( [lpUserID] => 1 [lpRoleID] => 1 [lpRoleName] => Programmer ) ) print_r($user) from inside _profile_get_fields($category=account, $register=): print_r($user) from inside user_access($string="administer users", $account=): stopping here because $users->roles is not an arrayThe beginning of the user_access function in user.module looks like:
Similar stuff is in profile.module without the die command if user->roles is not an array.
Comment #11
H3rnand3z commentedCould it be your authentication module clobbering $user object? I was getting similar errors using cac_lite and Webserver Auth module, new users started getting this error at first login.
If it helps, there is more info on the webserver_auth issue here http://drupal.org/node/64949
Comment #12
twibberjix commentedWhile I'm totally willing to entertain the idea that my code has somehow disrupted the natural order of all things Drupal - as I stated before:
I would not have created an issue if I thought it was my module screwing something up :(
The problem can be addressed by making the following modifications to profile.module:
For function profile_save_profile:
For function _profile_get_fields:
Comment #13
twibberjix commentedHere's a dummy authorization module that always returns true. If you enable it and profile.module and then log in with somerandomname@dummyauth and somerandompassword you should see the error. If you apply the changes I suggested to profile.module and then try logging in with a different randomname@dummyauth you should no longer see the error upon initial account creation.
Hope that helps for testing purposes.
Comment #14
damien tournoud commentedSeems that no actual bug has been identified here.