This bug is a tricky one.
You need:
a) An external authentication module
b) An external user who authenticates for the first time ever (so the user will be added to the drupal user database)
c) Pathauto activated with "verbose mode" enabled
Then you get the following three errors in log:
1. The first argument should be an array in /modules/user/user.module on line 361.
2. Bad arguments. in /modules/user/user.module on line 361.
3. 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 /includes/database.mysql.inc on line 172.
This is what happens:
user_authenticate tries to save the new user
line 1000: $user = user_save('', $userinfo);
During user_save we find a
line 199: user_module_invoke('insert', $array, $user, $category);
which fires pathauto_user, case 'insert' :
This functions does a pathauto_create_alias call (pathauto_user.inc, line 91).
pathauto_create_alias calls _pathauto_set_alias in line 381.
Finally in line 431 of _pathauto_set_alias we find a:
if ($verbose and user_access('create url aliases')) {
user_access does a global $user and guess what, we don't have a global $user yet, since we are not logged in (We are just in the middle of authentication, remember ?)
So $user = false and the above mentioned errors appear.
I attached a patch, which does the following:
Get the user object and check if we have an user.
global $user;
if ($verbose and $user and user_access('create url aliases')) {
This fixed the problem for me.
| Comment | File | Size | Author |
|---|---|---|---|
| patch_external_auth.txt | 982 bytes | Andreas Wolf |
Comments
Comment #1
gregglesInteresting problem - thanks for tracking it down!
I'd like to see some changes, though:
1) Standard is to use && instead of and - can you clean that up in this patch
2) The test for "and $user and" should ideally be isset($user) right? Basically using the variable as it's own test produces an undefined index php notice so using isset is E_ALL compliant.
Can you test out that second change and let me know? If it works I'll definitely commit the change.
Thanks!
Comment #2
gregglesPlease confirm whether this is still a problem in 5.x-2.0 branch of Pathauto.
I assume it's not (Junyor is using that version with ldapauth and didn't complain of this problem) and therefore close it because it takes quite a long time to setup/test this proposed patch.