Closed (fixed)
Project:
Pathauto
Version:
5.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Mar 2008 at 02:16 UTC
Updated:
23 Jan 2010 at 17:40 UTC
When users are created via hook_auth(), call to user_access which do not specify a $user will throw errors, as seen in profile.module here:
The same happens in pathauto when pathauto_user() fires on insert and only the uid is passed through, so when user_access is called at the top of pathauto_create_alias(), the following results:
* warning: array_keys() [function.array-keys]: The first argument should be an array in .../modules/user/user.module on line 401.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in .../modules/user/user.module on line 402.
* warning: implode() [function.implode]: Bad arguments. in .../modules/user/user.module on line 402.
* 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 .../includes/database.mysql.inc on line 172.
Comments
Comment #1
gregglesCan you clarify the exact steps to repeat and/or what you want Pathauto to do differently?
From a /very quick/ read this seems like it might be related to http://drupal.org/node/193733
Comment #2
Leeteq commentedComment #3
joshk commentedIt may be related. To see this in action, just use drupal.module distributed authentication and have pathauto set to alias users.
What's happening is that a call to user_access() is made in pathauto_create_alias(). When a user is added via remote authentication the full $user object isn't passed along to the invokation of hook_user, and so then you get errors from user_access().
Comment #4
gregglesAnd...what should pathauto do instead?
Comment #5
gregglesHere are the steps I followed:
1. Enable Drupal module
2. on admin/settings/distributed-authentication I set the authentication service to enabled and set drupal.org as the server - left all other defaults
3. On admin/settings/pathauto made sure that users had a pattern so an alias would be generated (tracker is installed as well, so that was being generated)
4. In a new browser, logged into the site using my greggles AT drupal.org address
Expected results:
User is logged in, alias is created
Actual results:
As expected...
So...I'm not sure why this works now but didn't before. Maybe the problem doesn't manifest itself in the Drupal module's authentication. Note that Junyor was able to fix this within the securesite module so I have a feeling that this is more of an issue with distributed authentication difficulties than it is with Pathauto. I'm still willing to find a solution in Pathauto...
Junyor assured me it was an error as well and I obviously trust both of you...I just don't know what the best solution should be.
1) If the $user object isn't complete then don't call user_access in Pathauto? That means that blog aliases won't be generated and, based on Junyor's example, it means that if there is a call to user_access later then it will still bomb out - not great.
2) Change core to make user_access more resilient so that it can handle getting junk data returning a FALSE. This is outside Pathauto and would mean that blog aliases don't get created when they probably should. Again, not ideal.
Something else?
Comment #6
dave reidNo follow-up from the original poster(s) in over a year, so marking as fixed.
Plus, not passing the full object is broken code, so Pathauto should not have to work around it.