Drupal + pgsql user.module SQL error with external auth (openid,jabber)
Got errors then logging to site first time.

* warning: array_keys() [function.array-keys]: The first argument
should be an array in
/opt/www/drupal/modules/user/user.module on line 368.
* warning: implode() [function.implode]: Bad arguments. in
/opt/www/drupal/modules/user/user.module on line 368.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax
error at or near ")" LINE 1: ...r INNER JOIN permission p ON p.rid = r.rid
WHERE r.rid IN () ^ in
/opt/www/drupal/includes/database.pgsql.inc on line 125.
* user warning: query: SELECT DISTINCT(p.perm) FROM role r INNER JOIN
permission p ON p.rid = r.rid WHERE r.rid IN () in
/opt/www/drupal/includes/database.pgsql.inc on line 144.

Simple patch:

--- user.module Thu Jul 26 23:16:50 2007
+++ user.module Sun Oct 7 09:41:22 2007
@@ -364,7 +364,7 @@

// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
- if (!isset($perm[$account->uid])) {
+ 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] = '';

CommentFileSizeAuthor
#2 user.module.sqlerror.patch598 bytesyagel

Comments

drumm’s picture

Status: Needs review » Active

Please attach a patch file, as described at http://drupal.org/patch/create

yagel’s picture

Title: Drupal + pgsql user.module SQL error with external auth » Drupal + user.module SQL error with external auth
Version: 5.2 » 5.5
StatusFileSize
new598 bytes

Attached patch works fine for me, please see it.

yagel’s picture

More details:
This bug appears when user with external auth module logging in first time (and his account auto-creating).

yagel’s picture

Version: 5.5 » 5.7
Status: Active » Needs review

present in latest release,
can be patched by
user.module.sqlerror.patch 598 bytes

cridenour’s picture

Title: Drupal + user.module SQL error with external auth » Roles error with External Auth
Version: 5.7 » 5.9
Status: Needs review » Reviewed & tested by the community

I confirm this works. As someone who is writing a external auth module, I am finding it impossible without doing a hack like recreating user_authenticate as ldap_integration does.

Please commit!

damien tournoud’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

This was a duplicate of #165642: error in SQL syntax in user.module on line 368 (or 378), that was fixed in 5.8. Please open a new ticket if you are still having issues.