Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1042
diff -u -p -r1.1042 user.module
--- modules/user/user.module	10 Sep 2009 12:33:45 -0000	1.1042
+++ modules/user/user.module	10 Sep 2009 18:25:19 -0000
@@ -672,10 +672,6 @@ function user_role_permissions($roles = 
  *   The permission, such as "administer nodes", being checked for.
  * @param $account
  *   (optional) The account to check, if not given use currently logged in user.
- * @param $reset
- *   (optional) Resets the user's permissions cache, which will result in a
- *   recalculation of the user's permissions. This is necessary to support
- *   dynamically added user roles.
  *
  * @return
  *   Boolean TRUE if the current user has the requested permission.
@@ -684,13 +680,9 @@ function user_role_permissions($roles = 
  * way, we guarantee consistent behavior, and ensure that the superuser
  * can perform all actions.
  */
-function user_access($string, $account = NULL, $reset = FALSE) {
+function user_access($string, $account = NULL) {
   global $user;
-  static $perm = array();
-
-  if ($reset) {
-    $perm = array();
-  }
+  $perm = &drupal_static(__FUNCTION__, array());
 
   if (!isset($account)) {
     $account = $user;
@@ -2316,7 +2308,7 @@ function user_role_delete($role) {
     ->execute();
 
   // Clear the user access cache.
-  user_access(NULL, NULL, TRUE);
+  drupal_static_reset('user_access');
 
   module_invoke_all('user_role_delete', $role);
 }
@@ -2352,7 +2344,7 @@ function user_role_set_permissions($role
   }
 
   // Clear the user access cache.
-  user_access(NULL, NULL, TRUE);
+  drupal_static_reset('user_access');
 
   return TRUE;
 }
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.60
diff -u -p -r1.60 user.test
--- modules/user/user.test	9 Sep 2009 11:36:02 -0000	1.60
+++ modules/user/user.test	10 Sep 2009 18:28:07 -0000
@@ -889,20 +889,22 @@ class UserPermissionsTestCase extends Dr
     $account = $this->admin_user;
 
     // Add a permission.
-    $this->assertFalse(user_access('administer nodes', $account, TRUE), t('User does not have "administer nodes" permission.'));
+    $this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.'));
     $edit = array();
     $edit[$rid . '[administer nodes]'] = TRUE;
     $this->drupalPost('admin/config/people/permissions', $edit, t('Save permissions'));
     $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
-    $this->assertTrue(user_access('administer nodes', $account, TRUE), t('User now has "administer nodes" permission.'));
+    drupal_static_reset('user_access');
+    $this->assertTrue(user_access('administer nodes', $account), t('User now has "administer nodes" permission.'));
 
     // Remove a permission.
-    $this->assertTrue(user_access('access user profiles', $account, TRUE), t('User has "access user profiles" permission.'));
+    $this->assertTrue(user_access('access user profiles', $account), t('User has "access user profiles" permission.'));
     $edit = array();
     $edit[$rid . '[access user profiles]'] = FALSE;
     $this->drupalPost('admin/config/people/permissions', $edit, t('Save permissions'));
     $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
-    $this->assertFalse(user_access('access user profiles', $account, TRUE), t('User no longer has "access user profiles" permission.'));
+    drupal_static_reset('user_access');
+    $this->assertFalse(user_access('access user profiles', $account), t('User no longer has "access user profiles" permission.'));
   }
 
   /**
@@ -923,7 +925,8 @@ class UserPermissionsTestCase extends Dr
     $edit['modules[Core][aggregator][enable]'] = TRUE;
     $this->drupalPost('admin/config/modules', $edit, t('Save configuration'));
 
-    $this->assertTrue(user_access('administer news feeds', $this->admin_user, TRUE), t('The permission was automatically assigned to the administrator role'));
+    drupal_static_reset('user_access');
+    $this->assertTrue(user_access('administer news feeds', $this->admin_user), t('The permission was automatically assigned to the administrator role'));
   }
 }
 
