When an external user is created on the first login using user_external_login_register() function, the hook profile_user() with operation 'insert' is triggered. At this stage there is no global $user defined, but an user object is passed as a variable $user to the profile_user() function.
profile_user() then calls a profile_save_profile() function and passes $user variable to it. profile_save_profile() function on the first line calls _profile_get_fields($category, $register) function, but does not pass the user object.
In the _profile_get_fields() function a user_access('administer users') is called, but since at this stage there is no global $user object defined, user_access() results in php error failing to build a sql statement.
Comments
Comment #1
agerson commentedI believe I am experiencing this issue. Here is an example error from a users first external login to the system:
warning: array_fill() [function.array-fill]: Number of elements must be positive in /Library/WebServer/Documents/drupal/includes/database.inc on line 240.
warning: implode() [function.implode]: Invalid arguments passed in /Library/WebServer/Documents/drupal/includes/database.inc on line 240.
warning: array_keys() [function.array-keys]: The first argument should be an array in /Library/WebServer/Documents/drupal/modules/user/user.module on line 500.
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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /Library/WebServer/Documents/drupal/modules/user/user.module on line 500.
Comment #2
Richard Blackborder commentedI'm also experiencing this problem, with similar error messages.
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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /www/htdocs/drupal/modules/user/user.module on line 500.
array_keys() [function.array-keys]: The first argument should be an array in /www/htdocs/drupal/modules/user/user.module on line 500.
implode() [function.implode]: Invalid arguments passed in /www/htdocs/drupal/includes/database.inc on line 240.
array_fill() [function.array-fill]: Number of elements must be positive in /www/htdocs/drupal/includes/database.inc on line 240.
I've temporarily hacked my user.module line 499 to this to stop the errors:
if (!isset($perm[$account->uid]) && $account->roles) {Comment #3
damien tournoud commentedThis is a duplicate of #165642: error in SQL syntax in user.module on line 368 (or 378).
Comment #4
kpolymorphic commentedMy temporary workaround for this (still having this issue in 6.16)
global $user;
$user = user_external_load($authname);
if(!$user) {
$user = new StdClass;
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
user_external_login_register($authname, 'modulename');
}
The $user global gets reset to a system value later on in the create cycle; so, this just gives the offending auth check a role to use.