diff --git a/libraries/Util.php b/libraries/Util.php index 2a9da68f4c..1188e145be 100644 --- a/libraries/Util.php +++ b/libraries/Util.php @@ -2781,6 +2781,20 @@ class Util self::cacheUnset('is_grantuser'); } + /** + * Calculates session cache key + * + * @return string + */ + public static function cacheKey() + { + if (isset($GLOBALS['cfg']['Server']['user'])) { + return 'server_' . $GLOBALS['server'] . '_' . $GLOBALS['cfg']['Server']['user']; + } else { + return 'server_' . $GLOBALS['server']; + } + } + /** * Verifies if something is cached in the session * @@ -2790,7 +2804,7 @@ class Util */ public static function cacheExists($var) { - return isset($_SESSION['cache']['server_' . $GLOBALS['server'] . '_' . $GLOBALS['cfg']['Server']['user']][$var]); + return isset($_SESSION['cache'][self::cacheKey()][$var]); } /** @@ -2804,7 +2818,7 @@ class Util public static function cacheGet($var, $callback = null) { if (self::cacheExists($var)) { - return $_SESSION['cache']['server_' . $GLOBALS['server'] . '_' . $GLOBALS['cfg']['Server']['user']][$var]; + return $_SESSION['cache'][self::cacheKey()][$var]; } else { if ($callback) { $val = $callback(); @@ -2825,7 +2839,7 @@ class Util */ public static function cacheSet($var, $val = null) { - $_SESSION['cache']['server_' . $GLOBALS['server'] . '_' . $GLOBALS['cfg']['Server']['user']][$var] = $val; + $_SESSION['cache'][self::cacheKey()][$var] = $val; } /** @@ -2837,7 +2851,7 @@ class Util */ public static function cacheUnset($var) { - unset($_SESSION['cache']['server_' . $GLOBALS['server'] . '_' . $GLOBALS['cfg']['Server']['user']][$var]); + unset($_SESSION['cache'][self::cacheKey()][$var]); } /**