I couldn't get another module to work correctly (CKEditor) and after lots of debugging found this issue:
views_plugin_argument_validate_user.inc line 98:
$account->roles = array();
$account->roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
$result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
while ($role = db_fetch_object($result)) {
$account->roles[] = $role->rid;
}
This causes a permission problem in the CKEditor module. But it seems like a major problem in the Views module, for two reasons:
1. It populates the roles array with no concern for RIDs as array keys. Many other modules rely on the keys of $account->roles to indicate the RID.
2. It populates the roles array of the account object even though these roles are already set. This leads to unnecessary db queries.
I checked out the latest dev version and the same code is still there (but on line 108).
Am I missing something? Any explanation for this code?
Comments
Comment #1
dawehnerThis is fixed already in 6.x-2.x-dev
Comment #2
olbion commentedI downloaded 6.x-3.x-dev. Looked at modules/user/views_plugin_argument_validate_user.inc line 109:
Then downloaded 6.x-3.0-alpha3. Same file, line 105:
Then 6.x-2.12. Same file, line 99:
So in which version do you mean that this is fixed?
Comment #3
merlinofchaos commentedAll of them. $account is a local variable not shared with other modules.
You should read *all* of the code.
Comment #4
dawehnerThere is a bug in 6.x-2.x, which changes $user.
Comment #6
olbion commentedI upgraded to 6.x-3.0-alpha3 and it solves the bug affecting CKEditor.
Thanks for your help. I still think the code is imperfect since it populates $account->roles in a non-standard way.
Comment #7
olbion commentedSorry, didn't mean to reopen the issue.
Comment #8
merlinofchaos commentedI agree, it should be bothering with $account at all, but it does not affect anything outside of itself, so it's just silly code and not really a bug at all.
Comment #10
oswajas commentedSee also #832954: global $user->roles get changed by argument_user_validate.
Comment #11
oswajas commentedSee also #832954: global $user->roles get changed by argument_user_validate