From: Tim Düsterhus Date: Thu, 9 Feb 2012 17:49:14 +0000 (+0100) Subject: Adding CacheClearAction X-Git-Tag: 2.0.0_Beta_1~1358^2~12^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=55bd5129a5c52053b7db341744c66813387d73ff;p=GitHub%2FWoltLab%2FWCF.git Adding CacheClearAction This class was handcoded with nano! --- diff --git a/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php new file mode 100644 index 0000000000..73f9beed7d --- /dev/null +++ b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php @@ -0,0 +1,57 @@ + + * @package com.woltlab.wcf + * @subpackage acp.action + * @category Community Framework + */ +class CacheClearAction extends AbstractAction { + /** + * @see wcf\action\IAction::execute() + */ + public function execute() { + parent::execute(); + WCF::getSession()->checkPermissions(array('admin.system.canViewLog')); + + // this will clean up the templates as well + LanguageFactory::getInstance()->deleteLanguageCache(); + + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $conditions->add("isApplication = ?", array(1)); + + // get package dirs + $sql = "SELECT packageDir + FROM wcf".WCF_N."_package + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']); + try { + CacheHandler::getInstance()->clear($packageDir.'cache', '*.php'); + } + catch (SystemException $e) { + } + } + $this->executed(); + HeaderUtil::redirect(LinkHandler::getInstance()->getLink('CacheList')); + exit; + } +}