Proper cache hit counting fixed
[mailer.git] / inc / wrapper-functions.php
index e23913c49b24c6ad72b7ca8b22340996cefeeb1f..48db9bbc05b706263abad490660594bfce5b9fb4 100644 (file)
@@ -368,8 +368,14 @@ function isSqlDebuggingEnabled () {
 
 // Checks wether we shall debug regular expressions
 function isDebugRegularExpressionEnabled () {
-       // Simply check it
-       return ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
+       // Is cache set?
+       if (!isset($GLOBALS['is_regular_exp_debug_enabled'])) {
+               // Simply check it
+               $GLOBALS['is_regular_exp_debug_enabled'] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
+       } // END - if
+
+       // Return it
+       return $GLOBALS['is_regular_exp_debug_enabled'];
 }
 
 // Checks wether the cache instance is valid
@@ -707,16 +713,32 @@ function redirectToDereferedUrl ($URL) {
 
 // Wrapper function for checking if extension is installed and newer or same version
 function isExtensionInstalledAndNewer ($ext_name, $version) {
+       // Is an cache entry found?
+       if (!isset($GLOBALS['ext_installed_newer'][$ext_name][$version])) {
+               $GLOBALS['ext_installed_newer'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
+       } else {
+               // Cache hits should be incremented twice
+               incrementStatsEntry('cache_hits', 2);
+       }
+
        // Return it
-       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=&gt;'.$version.'<br />';
-       return ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
+       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]).'<br />';
+       return $GLOBALS['ext_installed_newer'][$ext_name][$version];
 }
 
 // Wrapper function for checking if extension is installed and older than given version
 function isExtensionInstalledAndOlder ($ext_name, $version) {
+       // Is an cache entry found?
+       if (!isset($GLOBALS['ext_installed_older'][$ext_name][$version])) {
+               $GLOBALS['ext_installed_older'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
+       } else {
+               // Cache hits should be incremented twice
+               incrementStatsEntry('cache_hits', 2);
+       }
+
        // Return it
-       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'&lt;'.$version.'<br />';
-       return ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
+       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]).'<br />';
+       return $GLOBALS['ext_installed_older'][$ext_name][$version];
 }
 
 // Set username
@@ -750,7 +772,14 @@ function isInstallationPhase () {
 
 // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
 function isDemoModeActive () {
-       return ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo'));
+       // Is cache set?
+       if (!isset($GLOBALS['demo_mode_active'])) {
+               // Simply check it
+               $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo'));
+       } // END - if
+
+       // Return it
+       return $GLOBALS['demo_mode_active'];
 }
 
 // Getter for PHP caching value
@@ -874,14 +903,14 @@ function isDebuggingTemplateCache () {
 }
 
 // Wrapper for fetchUserData() and getUserData() calls
-function getFetchedUserData ($keyColumn, $userId, $valueColumn) {
+function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
        // Is it cached?
        if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) {
                // Default is 'guest'
                $data = getMessage('USERNAME_GUEST');
 
                // Can we fetch the user data?
-               if (($userId > 0) && (fetchUserData($userId, $keyColumn))) {
+               if (($userid > 0) && (fetchUserData($userid, $keyColumn))) {
                        // Now get the data back
                        $data = getUserData($valueColumn);
                } // END - if