From: Coleman Watts Date: Mon, 1 Feb 2016 23:57:11 +0000 (-0700) Subject: Fix broken caching in basicPermissions getter X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9476d8d1d4719d7c8550c6cbed920746685aecfe;p=civicrm-core.git Fix broken caching in basicPermissions getter --- diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 554d31d5a9..242fdf4074 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -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]; } /**