Proper cache hit counting fixed
[mailer.git] / inc / wrapper-functions.php
index 218bab23d89a1898550aac7930a50e4b42f1bdcd..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