From 9476d8d1d4719d7c8550c6cbed920746685aecfe Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 1 Feb 2016 16:57:11 -0700 Subject: [PATCH] Fix broken caching in basicPermissions getter --- CRM/Core/Permission.php | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) 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]; } /** -- 2.25.1