var $data = "";
var $version = "";
var $name = "";
+ var $rebuilt = array();
// Constructor
function CacheSystem ($interval, $path, $tested) {
$this->storeExtensionVersion("cache");
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
}
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
// Remove pointer
$this->pointer = false;
+ //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - FINALIZED!<br />\n";
} // END - if
}
}
} else {
// Cache file not found or not readable
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_LOAD_1.$this->inc.CACHE_CANNOT_LOAD_2);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_LOAD_1.$this->inc.CACHE_CANNOT_LOAD_2);
}
}
// Destroy an existing cache file
function destroyCacheFile () {
// Is the cache file there?
- if (FILE_READABLE($this->inc)) {
+ if ((!isset($this->rebuilt[$this->name])) && (FILE_READABLE($this->inc))) {
// Close cache
$this->finalize();
// Remove cache file from system
+ //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - DESTROYED!<br />\n";
unlink($this->inc);
// Is the file there?
if (!FILE_READABLE($this->inc)) {
// The cache does no longer exist so kill the content
unset($this->data[$this->name]);
+ unset($this->version[$this->name]);
+ $this->rebuilt[$this->name] = true;
} else {
// Not removed!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
}
- } else {
- // Does not exist!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
- }
+ } // END - if
}
// Unused method:
foreach ($array as $a) {
// So we can remove all elements as requested
unset($dummy[$a][$key]);
- }
+ } // END - foreach
// Flush array to cache file
$this->init();
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
} // END - foreach
} else {
// Cannot write array!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
if ($a == $search) {
// Update now...
$dummy[$a][$search_key] = $replace;
- }
- }
+ } // END - if
+ } // END - foreach
// Flush array to cache file
$this->init();
// Close cache file
$this->finalize();
- }
- }
+ } // END - if
+ } // END - if
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
// Write cache line to file
fwrite($this->pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n");
+
+ // Add the extension version to object (DO NOT REMOVE IT! Endless loop...)
+ $this->version[$this->name][$ext_name] = $ext_ver;
+ //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - {$ext_name}={$ext_ver}<br />\n";
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
+ addFatalMessage(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
// Get extension version
$ext_ver = GET_EXT_VERSION($ext_name);
+ // Debug messages
+ if (isset($this->version[$this->name][$ext_name])) {
+ //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): cache={$this->name},ext_name={$ext_name} - {$ext_ver}/{$this->version[$this->name][$ext_name]}<br />\n";
+ } else {
+ // No cache version found!
+ DEBUG_LOG(__METHOD__, __LINE__, "Cache {$this->name} has missing entry for extension {$ext_name}!");
+ }
+
// Compare both
return ((isset($this->version[$this->name][$ext_name])) && ($this->version[$this->name][$ext_name] == $ext_ver));
}
}
// Destroy the cache on extension changes
-function FILTER_CACHE_DESTROY_ON_EXT_CHANGE () {
+function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) {
global $cacheInstance;
- // Update cache
+ // Remove cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
- if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("extensions")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
} // END - if
+
+ // Return it
+ return $data;
}
// Destroy the cache on changing admin
function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () {
global $cacheInstance;
- // Update cache
+ // Remove cache
+ if (EXT_IS_ACTIVE("cache")) {
+ if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
+ } // END - if
+}
+
+// Destroy all cache files
+function FILTER_CACHE_DESTROY_ALL () {
+ global $cacheInstance;
+
+ // Remove cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->loadCacheFile("admin")) $cacheInstance->destroyCacheFile();
+ 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();
} // END - if
}
+// Filter for purging entire admin menu cache
+function FILTER_CACHE_PURGE_ADMIN_MENU () {
+ // Just call the function
+ CACHE_PURGE_ADMIN_MENU();
+}
+
//
?>