I located the source of my problem. In the user_access() function, the static variable $perm is set to hold the permissions for a user.
Issuing this command: user_access('', NULL, TRUE); (http://api.drupal.org/api/function/user_access/6) will unset the $perm variable and allow it to reset with the permissions from the most current roles. My debug code indicates that it contains the correct permissions from the roles of the $user object.
However, when I issue:
module_invoke($module, 'access', 'create', $type, $user);which, in the case of $module = 'node_content' will itself call
user_access($permission, $user),the $perm value is now set (as it should be from my reset command), but no longer contains the all permissions from the roles in the $user object (what was originally set), but only the ones you would find for the user in the role table. Furthermore, I put debug code into user_access() to show me each time it is ran. I do not see it accessed between the time $perm is unset (by my reset command) and it is called by module_invoke().
The way this worked in 5.x:
hook_init() would issue user_access('', NULL, TRUE) which would unset the $perm variable so that the next time user_access() ran, it would rebuild $perm. In 6.x appears this no longer works in the same way.
So, it looks like either:
a. Another module (other than the user.module) is manipulating the $perm variable, or;
b. Drupal core is assuring, when module_invoke() is used, that the set
$perm variable only contains roles that the user has in the roles table.
My question is this: Can the $perm variable be manipulated outside of the user.module? If not, then how is b. above accomplished?
Thanks for any assistance whatsoever!
-ron