Closed (duplicate)
Project:
Drupal core
Version:
5.0-rc1
Component:
user.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2007 at 01:51 UTC
Updated:
29 Jun 2008 at 19:10 UTC
I am trying to setup a site with distributed authentication from other site. The first time logging in give me below warning. Anyway, I could log in successfully.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /home/codenone/public_html/modules/user/user.module on line 359.
* warning: implode() [function.implode]: Bad arguments. in /home/codenone/public_html/modules/user/user.module on line 359.
* 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 role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /home/codenone/public_html/includes/database.mysql.inc on line 167.After some investication, $account used in user_access() is now 'false'. Probably the problem is in user_authenticate() while global $user is specified on the top of this function.
$user = user_load(array('name' => $name));
if (!$_user->uid) { // Register this new user.
$userinfo = array('name' => $name, 'pass' => user_password(), 'init' => $name, 'status' => 1);
if ($server) {
$userinfo["authname_$module"] = $name;
}
$user = user_save('', $userinfo);
watchdog('user', t('New external user: %user using module %module.', array('%user' => $name, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
break;
}
user_load() will return 'false' and it still remains as 'false' until user_save() return the correct one. During that period, user_access() is called with 'administer users'. Now I solve this problem in my site by below patch.
--- user.module.orig 2007-01-08 08:33:44.102988756 +0700
+++ user.module 2007-01-08 08:42:31.704088306 +0700
@@ -989,7 +989,7 @@
if ($server) {
$name .= '@'. $server;
}
- $user = user_load(array('name' => $name));
+ $_user = user_load(array('name' => $name));
if (!$_user->uid) { // Register this new user.
$userinfo = array('name' => $name, 'pass' => user_password(), 'init' => $name, 'status' => 1);
if ($server) {
@@ -999,6 +999,9 @@
watchdog('user', t('New external user: %user using module %module.', array('%user' => $name, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
break;
}
+ else {
+ $user = $_user;
+ }
}
}
}
Comments
Comment #1
ekes commentedI believe, different line numbers and versions but dupe of #165642: error in SQL syntax in user.module on line 368 (or 378) now fixed