*/
public static function resetCache() {
// reset cache
- CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.option-*.php', true);
+ CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.option-*.php');
// reset options.inc.php files
$sql = "SELECT package, packageID, packageDir
*/
public static function resetCache() {
// clear cache
- CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.groups*.php', true);
+ CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.groups*.php');
// clear sessions
SessionHandler::resetSessions();
* Loads the default cache resources.
*/
protected function loadDefaultCacheResources() {
- CacheHandler::getInstance()->addResource('languages', WCF_DIR.'cache/cache.languages.php', 'wcf\system\cache\CacheBuilderLanguage');
- CacheHandler::getInstance()->addResource('spiders', WCF_DIR.'cache/cache.spiders.php', 'wcf\system\cache\CacheBuilderSpider');
CacheHandler::getInstance()->addResource('languages', WCF_DIR.'cache/cache.languages.php', 'wcf\system\cache\builder\CacheBuilderLanguage');
CacheHandler::getInstance()->addResource('spiders', WCF_DIR.'cache/cache.spiders.php', 'wcf\system\cache\builder\CacheBuilderSpider');
if (defined('PACKAGE_ID')) {
- CacheHandler::getInstance()->addResource('coreObjects-'.PACKAGE_ID, WCF_DIR.'cache/cache.coreObjects-'.PACKAGE_ID.'.php', 'wcf\system\cache\CacheBuilderCoreObject');
CacheHandler::getInstance()->addResource('coreObjects-'.PACKAGE_ID, WCF_DIR.'cache/cache.coreObjects-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\CacheBuilderCoreObject');
}
}
* @param string $cache name of this resource
* @param string $file data file for this resource
* @param string $className
- * @param integer $minLifetime
* @param integer $maxLifetime
*/
- public function addResource($cache, $file, $className, $minLifetime = 0, $maxLifetime = 0) {
+ public function addResource($cache, $file, $className, $maxLifetime = 0) {
$this->cacheResources[$cache] = array(
'cache' => $cache,
'file' => $file,
'className' => $className,
- 'minLifetime' => $minLifetime,
'maxLifetime' => $maxLifetime
);
}
* Deletes a registered cache resource.
*
* @param string $cache
- * @param boolean $ignoreLifetime
*/
- public function clearResource($cache, $ignoreLifetime = false) {
+ public function clearResource($cache) {
if (!isset($this->cacheResources[$cache])) {
throw new SystemException("cache resource '".$cache."' does not exist", 11005);
}
- $this->getCacheSource()->delete($this->cacheResources[$cache], $ignoreLifetime);
+ $this->getCacheSource()->delete($this->cacheResources[$cache]);
}
/**
*
* @param string $directory
* @param string $filepattern
- * @param boolean $forceDelete
*/
- public function clear($directory, $filepattern, $forceDelete = false) {
- $this->getCacheSource()->clear($directory, $filepattern, $forceDelete);
+ public function clear($directory, $filepattern) {
+ $this->getCacheSource()->clear($directory, $filepattern);
}
/**
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-
-/**
- * Disables cache functions during the wcf setup.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.cache
- * @category Community Framework
- */
-class SetupCacheHandler extends CacheHandler {
- /**
- * @see CacheHandler::addResource()
- */
- public function addResource($cache, $file, $classFile, $minLifetime = 0, $maxLifetime = 0) {
- return false;
- }
-
- /**
- * @see CacheHandler::clearResource()
- */
- public function clearResource($cache, $ignoreLifetime = false) {
- return false;
- }
-
- /**
- * @see CacheHandler::clear()
- */
- public function clear($directory, $filepattern, $forceDelete = false) {
- return false;
- }
-
- /**
- * @see CacheHandler::get()
- */
- public function get($cache, $variable = '') {
- return false;
- }
-
- /**
- * @see CacheHandler::load()
- */
- public function load($cacheResource, $reload = false) {
- return false;
- }
-
- /**
- * @see CacheHandler::rebuild()
- */
- public function rebuild($cacheResource, $forceRebuilt = false) {
- return false;
- }
-}
/**
* @see wcf\system\cache\source\ICacheSource::delete()
*/
- public function delete(array $cacheResource, $ignoreLifetime = false) {
- if ($ignoreLifetime || ($cacheResource['minLifetime'] == 0 || $this->checkMinLifetime($cacheResource))) {
- apc_delete($cacheResource['file']);
- }
- }
-
- /**
- * Checks if the minimum lifetime is expired.
- *
- * @param array $cacheResource
- */
- public function checkMinLifetime(array $cacheResource) {
- $apcinfo = apc_cache_info('user');
- $cacheList = $apcinfo['cache_list'];
-
- foreach ($cacheList as $cache) {
- if ($cache['info'] == $cacheResource['file']) {
- return ((TIME_NOW - $cache['mtime']) >= $cacheResource['minLifetime']);
- }
- }
-
- return true;
+ public function delete(array $cacheResource) {
+ apc_delete($cacheResource['file']);
}
/**
* @see wcf\system\cache\source\ICacheSource::clear()
*/
- public function clear($directory, $filepattern, $forceDelete = false) {
+ public function clear($directory, $filepattern) {
$pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%').str_replace('*', '.*', str_replace('.', '\.', $filepattern));
$apcinfo = apc_cache_info('user');
}
// load resource
- $this->load($cacheResource);
+ if (!$this->load($cacheResource)) {
+ return null;
+ }
if (!isset($this->cache[$cacheResource['cache']])) {
return null;
/**
* @see wcf\system\cache\source\ICacheSource::delete()
*/
- public function delete(array$cacheResource, $ignoreLifetime = false) {
+ public function delete(array $cacheResource) {
if (file_exists($cacheResource['file'])) {
- if ($ignoreLifetime || ($cacheResource['minLifetime'] == 0 || (TIME_NOW - filemtime($cacheResource['file'])) >= $cacheResource['minLifetime'])) {
- // delete cache file
+ if (!@touch($cacheResource['file'], 1)) {
@unlink($cacheResource['file']);
+ }
- // reset open cache
- if (isset($this->cache[$cacheResource['cache']])) unset($this->cache[$cacheResource['cache']]);
- if (isset($this->loaded[$cacheResource['file']])) unset($this->loaded[$cacheResource['file']]);
+ // reset open cache
+ if (isset($this->cache[$cacheResource['cache']])) {
+ unset($this->cache[$cacheResource['cache']]);
+ }
+ if (isset($this->loaded[$cacheResource['file']])) {
+ unset($this->loaded[$cacheResource['file']]);
}
}
}
/**
* @see wcf\system\cache\source\ICacheSource::clear()
*/
- public function clear($directory, $filepattern, $forceDelete = false) {
+ public function clear($directory, $filepattern) {
+ // unify parameters
+ $directory = FileUtil::unifyDirSeperator($directory);
+ $filepattern = FileUtil::unifyDirSeperator($filepattern);
+
$filepattern = str_replace('*', '.*', str_replace('.', '\.', $filepattern));
if (substr($directory, -1) != '/') {
$directory .= '/';
}
- DirectoryUtil::getInstance($directory)->executeCallback(function ($filename) use ($forceDelete) {
- if ($forceDelete || !@touch($filename, 1)) {
+ DirectoryUtil::getInstance($directory)->executeCallback(function ($filename) {
+ if (!@touch($filename, 1)) {
@unlink($filename);
}
}, '%^'.$directory.$filepattern.'$%i');
return true;
}
- // cache resource has a delay marking
- if ($cacheResource['minLifetime'] > 0 && (TIME_NOW - $mtime) < $cacheResource['minLifetime']) {
- return false;
- }
-
// maxlifetime expired
if ($cacheResource['maxLifetime'] > 0 && (TIME_NOW - $mtime) > $cacheResource['maxLifetime']) {
return true;
* Deletes a variable in the cache.
*
* @param array $cacheResource
- * @param boolean $ignoreLifetime
*/
- public function delete(array $cacheResource, $ignoreLifetime = false);
+ public function delete(array $cacheResource);
/**
* Marks cached files as obsolete.
*
* @param string $directory
* @param string $filepattern
- * @param boolean $forceDelete
*/
- public function clear($directory, $filepattern, $forceDelete = false);
+ public function clear($directory, $filepattern);
/**
* Closes this cache source.
/**
* @see wcf\system\cache\source\ICacheSource::delete()
*/
- public function delete(array $cacheResource, $ignoreLifetime = false) {
+ public function delete(array $cacheResource) {
$this->getAdapter()->getMemcache()->delete($cacheResource['file']);
$this->removeFromLog($cacheResource['file']);
}
/**
* @see wcf\system\cache\source\ICacheSource::clear()
*/
- public function clear($directory, $filepattern, $forceDelete = false) {
+ public function clear($directory, $filepattern) {
$this->loadLog();
$pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%').str_replace('*', '.*', str_replace('.', '\.', $filepattern));
foreach ($this->cacheResources as $cacheResource) {
// sort out non matching files
if (!empty($pattern)) {
foreach ($files as $filename => $value) {
- if (((bool) preg_match($pattern, $filename)) == $negativeMatch) unset($files[$filename]);
+ if (((bool) preg_match($pattern, FileUtil::unifyDirSeperator($filename))) == $negativeMatch) unset($files[$filename]);
}
}
// sort out non matching files
if (!empty($pattern)) {
foreach ($objects as $filename => $value) {
- if (((bool) preg_match($pattern, $filename)) == $negativeMatch) unset($objects[$filename]);
+ if (((bool) preg_match($pattern, FileUtil::unifyDirSeperator($filename))) == $negativeMatch) unset($objects[$filename]);
}
}