Fix broken caching in basicPermissions getter
authorColeman Watts <coleman@civicrm.org>
Mon, 1 Feb 2016 23:57:11 +0000 (16:57 -0700)
committerColeman Watts <coleman@civicrm.org>
Mon, 1 Feb 2016 23:57:11 +0000 (16:57 -0700)
CRM/Core/Permission.php

index 554d31d5a908b5de17a031da48ec866e0071ef8d..242fdf40748f897f2b3fa50486a076458fbfeb2b 100644 (file)
@@ -553,30 +553,18 @@ class CRM_Core_Permission {
 
   /**
    * @param bool $all
+   *   Include disabled components
    * @param bool $descriptions
-   *   whether to return descriptions
+   *   Whether to return descriptions
    *
    * @return array
    */
-  public static function &basicPermissions($all = FALSE, $descriptions = FALSE) {
-    if ($descriptions) {
-      static $permissionsDesc = NULL;
-
-      if (!$permissionsDesc) {
-        $permissionsDesc = self::assembleBasicPermissions($all, $descriptions);
-      }
-
-      return $permissionsDesc;
-    }
-    else {
-      static $permissions = NULL;
-
-      if (!$permissions) {
-        $permissions = self::assembleBasicPermissions($all, $descriptions);
-      }
-
-      return $permissions;
+  public static function basicPermissions($all = FALSE, $descriptions = FALSE) {
+    $cacheKey = implode('-', array($all, $descriptions));
+    if (empty(Civi::$statics[__CLASS__][__FUNCTION__][$cacheKey])) {
+      Civi::$statics[__CLASS__][__FUNCTION__][$cacheKey] = self::assembleBasicPermissions($all, $descriptions);
     }
+    return Civi::$statics[__CLASS__][__FUNCTION__][$cacheKey];
   }
 
   /**