X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Flibs%2Fcache_functions.php;h=98d29819ab9801c8780f0a95756d55f43c974191;hb=59bd8a9805c51c895a92cc12825f4cbdfd792597;hp=392827f683f83953d2ebdf66529ee1023b17bc9b;hpb=3e67aa21428cb9bc5b8d7552d2dd0770fc46dfb3;p=mailer.git
diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php
index 392827f683..98d29819ab 100644
--- a/inc/libs/cache_functions.php
+++ b/inc/libs/cache_functions.php
@@ -84,12 +84,12 @@ class CacheSystem {
}
// Checks validity of cache file and if content is given
- function loadCacheFile ($file, $forceContent = false) {
+ function loadCacheFile ($cacheName, $forceContent = false) {
// Remember cache file
- $this->name = $file;
+ $this->name = $cacheName;
// Construct FQFN (full qualified file name)
- $this->inc = $this->path.$file.".cache";
+ $this->inc = $this->path . $cacheName . ".cache";
// Check if file exists and if version matches
$status = (FILE_READABLE($this->inc) && (is_writeable($this->inc)) && ($this->extensionVersionMatches("cache")));
@@ -112,25 +112,24 @@ class CacheSystem {
$this->storeExtensionVersion("cache");
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
function addRow ($data) {
- global $cacheArray;
-
+ // Is the pointe rvalid?
if (is_resource($this->pointer)) {
// Write every array element to cache file
foreach ($data as $k => $v) {
// Write global cache array for immediate access
if ((substr($k, 0, 4) == "ext_") && (isset($data['ext_name'])) && (isset($data['ext_id']))) {
if ($k != "ext_name") {
- $cacheArray['extensions'][$k][$data['ext_name']] = $v;
+ $GLOBALS['cache_array']['extensions'][$k][$data['ext_name']] = $v;
} else {
- $cacheArray['extensions'][$k][$data['ext_id']] = $v;
+ $GLOBALS['cache_array']['extensions'][$k][$data['ext_id']] = $v;
}
if (($k == "ext_keep") && ($v == "Y")) {
- $cacheArray['active_extensions'][$data['ext_name']] = $v;
+ $GLOBALS['cache_array']['active_extensions'][$data['ext_name']] = $v;
} // END - if
} elseif (is_array($v)) {
// Serialize and BASE64-encode the array
@@ -142,7 +141,7 @@ class CacheSystem {
}
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -178,7 +177,7 @@ class CacheSystem {
$cache_version = null;
// Load cache file
- require_once($this->inc);
+ LOAD_INC_ONCE($this->inc);
// Is there an array?
if (is_array($data)) {
@@ -205,7 +204,7 @@ class CacheSystem {
}
} else {
// Cache file not found or not readable
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->inc.CACHE_CANNOT_LOAD_2);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->inc.CACHE_CANNOT_LOAD_2);
}
}
@@ -228,12 +227,9 @@ class CacheSystem {
$this->rebuilt[$this->name] = true;
} else {
// Not removed!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
}
- } else {
- // Does not exist!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
- }
+ } // END - if
}
// Unused method:
@@ -262,7 +258,7 @@ class CacheSystem {
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -286,7 +282,7 @@ class CacheSystem {
} // END - foreach
} else {
// Cannot write array!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -323,7 +319,7 @@ class CacheSystem {
} // END - if
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -341,7 +337,7 @@ class CacheSystem {
//* DEBUG: */ print __METHOD__."(".__LINE__."): {$this->name} - {$ext_name}={$ext_ver}
\n";
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -398,43 +394,37 @@ class CacheSystem {
// Destroy the cache on extension changes
function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) {
- global $cacheInstance;
-
// Remove cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("extensions")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("config")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("extensions")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("mod_reg")) $GLOBALS['cache_instance']->destroyCacheFile();
} // END - if
// Return it
- return $DATA;
+ return $data;
}
// Destroy the cache on changing admin
function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () {
- global $cacheInstance;
-
// Remove cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("admins")) $GLOBALS['cache_instance']->destroyCacheFile();
} // END - if
}
// Destroy all cache files
function FILTER_CACHE_DESTROY_ALL () {
- global $cacheInstance;
-
// Remove cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("extensions")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("refdepths")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("refsystem")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("themes")) $cacheInstance->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("admins")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("admins_acls")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("config")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("extensions")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("mod_reg")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("refdepths")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("refsystem")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile("themes")) $GLOBALS['cache_instance']->destroyCacheFile();
} // END - if
}