Further fixes for installation phase and endless loop
[mailer.git] / inc / classes / cachesystem.class.php
index 61a6fe31458002ceeb7b05dd936df47e39297add..6a1992dd9d371e5145304a1a3ad7473df0a69a54 100644 (file)
@@ -115,8 +115,7 @@ class CacheSystem {
                // This will destory an existing cache file!
                if ($this->ret == $this->statusDone) {
                        // Mark it as no longer readable
-                       unset($this->readable[$this->name]);
-                       unset($GLOBALS['file_readable'][$this->fqfn]);
+                       $this->markCacheAsUnreadable();
 
                        // Create file
                        if ($this->isCacheReadable()) changeMode($this->fqfn, 0666);
@@ -130,6 +129,12 @@ class CacheSystem {
                }
        }
 
+       // Mark the cache as unreadable
+       function markCacheAsUnreadable () {
+               unset($this->readable[$this->name]);
+               unset($GLOBALS['file_readable'][$this->fqfn]);
+       }
+
        function addRow ($data) {
                // Is the pointe rvalid?
                if (is_resource($this->pointer)) {
@@ -217,11 +222,17 @@ class CacheSystem {
                } else {
                        // Cache file not found or not readable
                        addFatalMessage(__METHOD__, __LINE__, "(<font color=\"#0000aa\">".__LINE__."</font>): ".sprintf(getMessage('CACHE_CANNOT_LOAD'), $this->fqfn));
+
+                       // Try to remove it
+                       $this->removeCacheFile();
                }
        }
 
        // Destroy an existing cache file
        function removeCacheFile ($removeArray = false, $force = false) {
+               // Remove cached value of readable cache
+               $this->markCacheAsUnreadable();
+
                // Debug message
                /* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("%s should be removed.", $this->name));
 
@@ -251,9 +262,6 @@ class CacheSystem {
                        // Remove cache file from system
                        removeFile($this->fqfn);
 
-                       // No longer readable!
-                       unset($this->readable[$this->name]);
-
                        // Shall we remove the array from memory?
                        if ($removeArray === true) {
                                // Debug message if allowed