From b401cd0d4ae6946e4fd14daacd65ec559e010081 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 4 Feb 2013 15:45:47 +0100 Subject: [PATCH] Major overhaul of caching system (work in progress) See #1124 --- .../lib/acp/action/CacheClearAction.class.php | 19 +- .../acp/action/InstallPackageAction.class.php | 16 +- .../acp/form/AbstractOptionListForm.class.php | 8 +- .../LanguageMultilingualismForm.class.php | 4 +- .../lib/acp/form/UserGroupAddForm.class.php | 5 - .../lib/acp/form/UserOptionListForm.class.php | 5 - .../files/lib/acp/page/UserListPage.class.php | 11 +- .../application/ApplicationEditor.class.php | 6 +- .../data/category/CategoryEditor.class.php | 6 +- .../listener/CleanupListener.class.php | 25 --- .../listener/CleanupListenerAction.class.php | 20 --- .../listener/CleanupListenerEditor.class.php | 20 --- .../listener/CleanupListenerList.class.php | 20 --- .../lib/data/cronjob/CronjobEditor.class.php | 6 +- .../data/language/LanguageEditor.class.php | 6 +- .../object/type/ObjectTypeCache.class.php | 17 +- .../lib/data/option/OptionEditor.class.php | 6 +- .../lib/data/package/PackageCache.class.php | 11 +- .../lib/data/package/PackageEditor.class.php | 4 +- .../menu/item/PageMenuItemEditor.class.php | 6 +- .../lib/data/style/StyleEditor.class.php | 6 +- .../files/lib/data/user/User.class.php | 11 +- .../lib/data/user/group/UserGroup.class.php | 11 +- .../data/user/group/UserGroupEditor.class.php | 8 +- .../option/UserGroupOptionEditor.class.php | 6 +- .../install/files/lib/system/WCF.class.php | 23 +-- .../install/files/lib/system/WCFACP.class.php | 11 +- .../files/lib/system/WCFSetup.class.php | 4 +- .../files/lib/system/acl/ACLHandler.class.php | 12 +- .../application/ApplicationHandler.class.php | 11 +- .../lib/system/cache/CacheHandler.class.php | 9 +- ...TemplateListenerCodeCacheBuilder.class.php | 9 +- .../system/category/CategoryHandler.class.php | 15 +- .../CategoryPermissionHandler.class.php | 13 +- .../system/cleanup/CleanupHandler.class.php | 169 ------------------ .../system/cleanup/ICleanupAdapter.class.php | 21 --- .../clipboard/ClipboardHandler.class.php | 19 +- .../system/cronjob/CronjobScheduler.class.php | 13 +- .../RefreshSearchRobotsCronjob.class.php | 6 +- .../lib/system/event/EventHandler.class.php | 11 +- .../system/language/LanguageFactory.class.php | 14 +- .../lib/system/menu/acp/ACPMenu.class.php | 11 +- .../lib/system/menu/page/PageMenu.class.php | 9 +- .../lib/system/option/OptionHandler.class.php | 26 +-- .../PackageInstallationDispatcher.class.php | 13 +- .../PackageUninstallationDispatcher.class.php | 20 +-- ...roviderPackageInstallationPlugin.class.php | 6 +- ...eObjectPackageInstallationPlugin.class.php | 6 +- ...istenerPackageInstallationPlugin.class.php | 6 +- .../ScriptPackageInstallationPlugin.class.php | 4 +- ...SitemapPackageInstallationPlugin.class.php | 6 +- ...istenerPackageInstallationPlugin.class.php | 9 +- .../search/acp/ACPSearchHandler.class.php | 12 +- .../system/session/SessionHandler.class.php | 17 +- .../system/sitemap/SitemapHandler.class.php | 11 +- .../lib/system/style/StyleHandler.class.php | 11 +- .../system/template/TemplateEngine.class.php | 58 ++---- .../system/version/VersionHandler.class.php | 14 +- wcfsetup/setup/db/install.sql | 23 --- 59 files changed, 195 insertions(+), 690 deletions(-) delete mode 100644 wcfsetup/install/files/lib/data/cleanup/listener/CleanupListener.class.php delete mode 100644 wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerAction.class.php delete mode 100644 wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerEditor.class.php delete mode 100644 wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerList.class.php delete mode 100644 wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php delete mode 100644 wcfsetup/install/files/lib/system/cleanup/ICleanupAdapter.class.php diff --git a/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php index 273d756c3f..05e5929181 100644 --- a/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php @@ -2,19 +2,17 @@ namespace wcf\acp\action; use wcf\action\AbstractAction; use wcf\system\cache\CacheHandler; -use wcf\system\exception\SystemException; use wcf\system\language\LanguageFactory; use wcf\system\request\LinkHandler; use wcf\system\style\StyleHandler; use wcf\system\WCF; -use wcf\util\FileUtil; use wcf\util\HeaderUtil; /** * Clears the cache. * - * @author Tim Düsterhus - * @copyright 2012 Tim Düsterhus + * @author Tim Duesterhus + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage acp.action @@ -39,18 +37,7 @@ class CacheClearAction extends AbstractAction { LanguageFactory::getInstance()->deleteLanguageCache(); // get package dirs - $sql = "SELECT packageDir - FROM wcf".WCF_N."_package - WHERE isApplication = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array(1)); - while ($row = $statement->fetchArray()) { - $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']); - try { - CacheHandler::getInstance()->clear($packageDir.'cache', '*.php'); - } - catch (SystemException $e) { } - } + CacheHandler::getInstance()->flushAll(); $this->executed(); HeaderUtil::redirect(LinkHandler::getInstance()->getLink('CacheList')); diff --git a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php index dde534ad5d..ad7b32c8c3 100755 --- a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php @@ -6,14 +6,13 @@ use wcf\system\cache\CacheHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\package\PackageInstallationDispatcher; use wcf\system\WCF; -use wcf\util\FileUtil; use wcf\util\StringUtil; /** * Handles an AJAX-based package installation. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage acp.action @@ -224,17 +223,6 @@ class InstallPackageAction extends AbstractDialogAction { * Clears resources after successful installation. */ protected function finalize() { - // clear cache - $sql = "SELECT packageDir - FROM wcf".WCF_N."_package - WHERE isApplication = 1"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - - while ($row = $statement->fetchArray()) { - $cacheDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir'] . 'cache/'); - - CacheHandler::getInstance()->clear($cacheDir, '*.php'); - } + CacheHandler::getInstance()->flushAll(); } } diff --git a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php index 64190dd635..dee75cf445 100755 --- a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php @@ -24,12 +24,6 @@ abstract class AbstractOptionListForm extends AbstractForm { */ public $errorType = array(); - /** - * cache name - * @var string - */ - public $cacheName = 'option'; - /** * cache class name * @var string @@ -72,7 +66,7 @@ abstract class AbstractOptionListForm extends AbstractForm { public function readParameters() { parent::readParameters(); - $this->optionHandler = new $this->optionHandlerClassName($this->cacheName, $this->cacheClass, $this->supportI18n, $this->languageItemPattern, $this->categoryName); + $this->optionHandler = new $this->optionHandlerClassName($this->cacheClass, $this->supportI18n, $this->languageItemPattern, $this->categoryName); $this->initOptionHandler(); } diff --git a/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php index 1ee730f607..78af10098c 100644 --- a/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php @@ -2,7 +2,7 @@ namespace wcf\acp\form; use wcf\data\language\LanguageEditor; use wcf\form\AbstractForm; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\LanguageCacheBuilder; use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\WCF; @@ -92,7 +92,7 @@ class LanguageMultilingualismForm extends AbstractForm { LanguageEditor::enableMultilingualism(($this->enable == 1 ? $this->languageIDs : array())); // clear cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.language.php'); + LanguageCacheBuilder::getInstance()->reset(); $this->saved(); // show success message diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php index d101e978cd..22b37a2157 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php @@ -31,11 +31,6 @@ class UserGroupAddForm extends AbstractOptionListForm { */ public $menuItemName = 'wcf.acp.menu.link.group.add'; - /** - * @see wcf\acp\form\AbstractOptionListForm::$cacheName - */ - public $cacheName = 'userGroupOption'; - /** * option tree * @var array diff --git a/wcfsetup/install/files/lib/acp/form/UserOptionListForm.class.php b/wcfsetup/install/files/lib/acp/form/UserOptionListForm.class.php index 68306ae337..d7cc1c9a9c 100644 --- a/wcfsetup/install/files/lib/acp/form/UserOptionListForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserOptionListForm.class.php @@ -14,11 +14,6 @@ use wcf\system\language\LanguageFactory; * @category Community Framework */ abstract class UserOptionListForm extends AbstractOptionListForm { - /** - * @see wcf\acp\form\AbstractOptionListForm::$cacheName - */ - public $cacheName = 'userOption'; - /** * @see wcf\acp\form\AbstractOptionListForm::$supportI18n */ diff --git a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php index 9fadcb72e1..456a8299ba 100755 --- a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php @@ -4,7 +4,7 @@ use wcf\data\user\group\UserGroup; use wcf\data\user\option\ViewableUserOption; use wcf\data\user\User; use wcf\page\SortablePage; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserOptionCacheBuilder; use wcf\system\clipboard\ClipboardHandler; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\event\EventHandler; @@ -18,7 +18,7 @@ use wcf\util\StringUtil; * Shows the result of a user search. * * @author Marcel Werk - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage acp.page @@ -312,12 +312,7 @@ class UserListPage extends SortablePage { * Gets the user options from cache. */ protected function readUserOptions() { - CacheHandler::getInstance()->addResource( - 'userOption', - WCF_DIR.'cache/cache.userOption.php', - 'wcf\system\cache\builder\OptionCacheBuilder' - ); - $this->options = CacheHandler::getInstance()->get('userOption', 'options'); + $this->options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options'); foreach ($this->options as &$option) { $option = new ViewableUserOption($option); diff --git a/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php b/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php index 17934d2503..a30d7a5633 100644 --- a/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php +++ b/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php @@ -2,14 +2,14 @@ namespace wcf\data\application; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\ApplicationCacheBuilder; use wcf\system\WCF; /** * Provides functions to edit applications. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.application @@ -88,6 +88,6 @@ class ApplicationEditor extends DatabaseObjectEditor implements IEditableCachedO * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.application.php'); + ApplicationCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php b/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php index ccd4304169..7abafb7595 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php @@ -2,7 +2,7 @@ namespace wcf\data\category; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CategoryCacheBuilder; use wcf\system\category\CategoryHandler; use wcf\system\WCF; @@ -10,7 +10,7 @@ use wcf\system\WCF; * Provides functions to edit categories. * * @author Matthias Schmidt - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.category @@ -213,6 +213,6 @@ class CategoryEditor extends DatabaseObjectEditor implements IEditableCachedObje * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.category.php'); + CategoryCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListener.class.php b/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListener.class.php deleted file mode 100644 index b5cb6db9f8..0000000000 --- a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListener.class.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.cleanup.listener - * @category Community Framework - */ -class CleanupListener extends DatabaseObject { - /** - * @see wcf\data\DatabaseObject::$databaseTableName - */ - protected static $databaseTableName = 'cleanup_listener'; - - /** - * @see wcf\data\DatabaseObject::$databaseTableIndexName - */ - protected static $databaseTableIndexName = 'listenerID'; -} diff --git a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerAction.class.php b/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerAction.class.php deleted file mode 100644 index 731aff18a6..0000000000 --- a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerAction.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.cleanup.listener - * @category Community Framework - */ -class CleanupListenerAction extends AbstractDatabaseObjectAction { - /** - * @see wcf\data\AbstractDatabaseObjectAction::$className - */ - protected $className = 'wcf\data\cleanup\listener\CleanupListenerEditor'; -} diff --git a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerEditor.class.php b/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerEditor.class.php deleted file mode 100644 index ccd9669a93..0000000000 --- a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerEditor.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.cleanup.listener - * @category Community Framework - */ -class CleanupListenerEditor extends DatabaseObjectEditor { - /** - * @see wcf\data\DatabaseObjectDecorator::$baseClass - */ - public $baseClass = 'wcf\data\cleanup\listener\CleanupListener'; -} diff --git a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerList.class.php b/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerList.class.php deleted file mode 100644 index fddd31f10a..0000000000 --- a/wcfsetup/install/files/lib/data/cleanup/listener/CleanupListenerList.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.cleanup.listener - * @category Community Framework - */ -class CleanupListenerList extends DatabaseObjectList { - /** - * @see wcf\data\DatabaseObjectList::$className - */ - public $className = 'wcf\data\cleanup\listener\CleanupListener'; -} diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php index dc215363d0..d04bdc02d8 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobEditor.class.php @@ -3,7 +3,7 @@ namespace wcf\data\cronjob; use wcf\data\language\LanguageList; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CronjobCacheBuilder; use wcf\system\language\LanguageFactory; use wcf\system\WCF; @@ -11,7 +11,7 @@ use wcf\system\WCF; * Provides functions to edit cronjobs. * * @author Alexander Ebert, Matthias Schmidt - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.cronjob @@ -110,6 +110,6 @@ class CronjobEditor extends DatabaseObjectEditor implements IEditableCachedObjec * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.cronjob.php'); + CronjobCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index 0b569cca55..204b3d389c 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -6,7 +6,7 @@ use wcf\data\language\item\LanguageItemEditor; use wcf\data\language\item\LanguageItemList; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\LanguageCacheBuilder; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\io\File; @@ -21,7 +21,7 @@ use wcf\util\XML; * Provides functions to edit languages. * * @author Alexander Ebert - * @copyright 2001-2011 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.language @@ -507,7 +507,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje * Clears language cache. */ public function clearCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.language.php'); + LanguageCacheBuilder::getInstance()->reset(); } /** diff --git a/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php b/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php index 2b9626a600..45d4317d77 100644 --- a/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php +++ b/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage data.object.type @@ -49,19 +49,14 @@ class ObjectTypeCache extends SingletonFactory { */ protected function init() { // get definition cache - CacheHandler::getInstance()->addResource( - 'objectType', - WCF_DIR.'cache/cache.objectType.php', - 'wcf\system\cache\builder\ObjectTypeCacheBuilder' - ); - $this->definitionsByCategory = CacheHandler::getInstance()->get('objectType', 'categories'); - $this->definitions = CacheHandler::getInstance()->get('objectType', 'definitions'); + $this->definitionsByCategory = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'categories'); + $this->definitions = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'definitions'); foreach ($this->definitions as $definition) { $this->definitionsByName[$definition->definitionName] = $definition; } // get object type cache - $this->objectTypes = CacheHandler::getInstance()->get('objectType', 'objectTypes'); + $this->objectTypes = ObjectTypeCacheBuilder::getInstance()->getData(array(), 'objectTypes'); foreach ($this->objectTypes as $objectType) { $definition = $this->getDefinition($objectType->definitionID); if (!isset($this->groupedObjectTypes[$definition->definitionName])) { @@ -171,7 +166,7 @@ class ObjectTypeCache extends SingletonFactory { * Resets and reloads the object type cache. */ public function resetCache() { - CacheHandler::getInstance()->clearResource('objectType'); + ObjectTypeCacheBuilder::getInstance()->reset(); $this->init(); } } diff --git a/wcfsetup/install/files/lib/data/option/OptionEditor.class.php b/wcfsetup/install/files/lib/data/option/OptionEditor.class.php index 2355433268..073704b4b8 100644 --- a/wcfsetup/install/files/lib/data/option/OptionEditor.class.php +++ b/wcfsetup/install/files/lib/data/option/OptionEditor.class.php @@ -2,7 +2,7 @@ namespace wcf\data\option; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\OptionCacheBuilder; use wcf\system\io\File; use wcf\system\WCF; use wcf\util\FileUtil; @@ -11,7 +11,7 @@ use wcf\util\FileUtil; * Provides functions to edit options. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.option @@ -82,7 +82,7 @@ class OptionEditor extends DatabaseObjectEditor implements IEditableCachedObject */ public static function resetCache() { // reset cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.option.php'); + OptionCacheBuilder::getInstance()->reset(); // reset options.inc.php files self::rebuild(); diff --git a/wcfsetup/install/files/lib/data/package/PackageCache.class.php b/wcfsetup/install/files/lib/data/package/PackageCache.class.php index 0b86f76a5e..61073a54cd 100644 --- a/wcfsetup/install/files/lib/data/package/PackageCache.class.php +++ b/wcfsetup/install/files/lib/data/package/PackageCache.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage data.package @@ -24,12 +24,7 @@ class PackageCache extends SingletonFactory { * @see wcf\system\SingletonFactory::init() */ protected function init() { - CacheHandler::getInstance()->addResource( - 'package', - WCF_DIR.'cache/cache.package.php', - 'wcf\system\cache\builder\PackageCacheBuilder' - ); - $this->packages = CacheHandler::getInstance()->get('package'); + $this->packages = PackageCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/data/package/PackageEditor.class.php b/wcfsetup/install/files/lib/data/package/PackageEditor.class.php index b1e2f09b83..c5e1bf46a7 100644 --- a/wcfsetup/install/files/lib/data/package/PackageEditor.class.php +++ b/wcfsetup/install/files/lib/data/package/PackageEditor.class.php @@ -2,7 +2,7 @@ namespace wcf\data\package; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\PackageCacheBuilder; /** * Provides functions to edit packages. @@ -24,6 +24,6 @@ class PackageEditor extends DatabaseObjectEditor implements IEditableCachedObjec * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.package.php'); + PackageCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php index c632a92ffb..3dbfc01ae9 100644 --- a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php +++ b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php @@ -2,14 +2,14 @@ namespace wcf\data\page\menu\item; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\PageMenuCacheBuilder; use wcf\system\WCF; /** * Provides functions to edit page menu items. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.page.menu.item @@ -152,6 +152,6 @@ class PageMenuItemEditor extends DatabaseObjectEditor implements IEditableCached * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.pageMenu.php'); + PageMenuCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index 44f8f8b400..bd2018f9b5 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -7,7 +7,7 @@ use wcf\data\template\group\TemplateGroupEditor; use wcf\data\template\TemplateEditor; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\StyleCacheBuilder; use wcf\system\exception\SystemException; use wcf\system\image\ImageHandler; use wcf\system\io\Tar; @@ -27,7 +27,7 @@ use wcf\util\XMLWriter; * Provides functions to edit, import, export and delete a style. * * @author Marcel Werk - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.style @@ -935,7 +935,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.style.php'); + StyleCacheBuilder::getInstance()->reset(); } /** diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 233a99d559..4c586e4e8c 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -4,7 +4,7 @@ use wcf\data\user\group\UserGroup; use wcf\data\user\UserList; use wcf\data\DatabaseObject; use wcf\system\api\rest\response\IRESTfulResponse; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserOptionCacheBuilder; use wcf\system\language\LanguageFactory; use wcf\system\request\IRouteController; use wcf\system\user\storage\UserStorageHandler; @@ -15,7 +15,7 @@ use wcf\util\PasswordUtil; * Represents a user. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.user @@ -241,12 +241,7 @@ final class User extends DatabaseObject implements IRESTfulResponse, IRouteContr * Gets all user options from cache. */ protected static function getUserOptionCache() { - CacheHandler::getInstance()->addResource( - 'userOption', - WCF_DIR.'cache/cache.userOption.php', - 'wcf\system\cache\builder\OptionCacheBuilder' - ); - self::$userOptions = CacheHandler::getInstance()->get('userOption', 'options'); + self::$userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options'); } /** diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index 4f201da395..d5ed25616b 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -2,7 +2,7 @@ namespace wcf\data\user\group; use wcf\data\user\User; use wcf\data\DatabaseObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserGroupCacheBuilder; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\WCF; @@ -11,7 +11,7 @@ use wcf\system\WCF; * Represents a user group. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.user.group @@ -219,12 +219,7 @@ class UserGroup extends DatabaseObject { */ protected static function getCache() { if (self::$cache === null) { - CacheHandler::getInstance()->addResource( - 'userGroup', - WCF_DIR.'cache/cache.userGroup.php', - 'wcf\system\cache\builder\UserGroupCacheBuilder' - ); - self::$cache = CacheHandler::getInstance()->get('userGroup'); + self::$cache = UserGroupCacheBuilder::getInstance()->getData(); } } diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php index fe2ccec302..572366be96 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroupEditor.class.php @@ -2,7 +2,8 @@ namespace wcf\data\user\group; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserGroupCacheBuilder; +use wcf\system\cache\builder\UserGroupPermissionCacheBuilder; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\session\SessionHandler; use wcf\system\WCF; @@ -11,7 +12,7 @@ use wcf\system\WCF; * Provides functions to edit user groups. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.user.group @@ -179,7 +180,8 @@ class UserGroupEditor extends DatabaseObjectEditor implements IEditableCachedObj */ public static function resetCache() { // clear cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.userGroup*'); + UserGroupCacheBuilder::getInstance()->reset(); + UserGroupPermissionCacheBuilder::getInstance()->reset(); // clear sessions SessionHandler::resetSessions(); diff --git a/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionEditor.class.php b/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionEditor.class.php index 736994042d..c4a3f96221 100644 --- a/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionEditor.class.php @@ -2,13 +2,13 @@ namespace wcf\data\user\group\option; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserGroupOptionCacheBuilder; /** * Provides functions to edit usergroup options. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.user.group.option @@ -24,6 +24,6 @@ class UserGroupOptionEditor extends DatabaseObjectEditor implements IEditableCac * @see wcf\data\IEditableCachedObject::resetCache() */ public static function resetCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.userGroup*.php'); + UserGroupOptionCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 03514eab69..deb265696a 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -6,7 +6,7 @@ use wcf\data\package\Package; use wcf\data\package\PackageCache; use wcf\data\package\PackageEditor; use wcf\system\application\ApplicationHandler; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CoreObjectCacheBuilder; use wcf\system\cronjob\CronjobScheduler; use wcf\system\exception\IPrintableException; use wcf\system\exception\PermissionDeniedException; @@ -300,24 +300,7 @@ class WCF { * Loads the default cache resources. */ protected function loadDefaultCacheResources() { - CacheHandler::getInstance()->addResource( - 'language', - WCF_DIR.'cache/cache.language.php', - 'wcf\system\cache\builder\LanguageCacheBuilder' - ); - CacheHandler::getInstance()->addResource( - 'spider', - WCF_DIR.'cache/cache.spider.php', - 'wcf\system\cache\builder\SpiderCacheBuilder' - ); - - if (defined('PACKAGE_ID')) { - CacheHandler::getInstance()->addResource( - 'coreObject', - WCF_DIR.'cache/cache.coreObject.php', - 'wcf\system\cache\builder\CoreObjectCacheBuilder' - ); - } + // TODO: Is this required anymore? } /** @@ -520,7 +503,7 @@ class WCF { return; } - self::$coreObjectCache = CacheHandler::getInstance()->get('coreObject'); + self::$coreObjectCache = CoreObjectCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/WCFACP.class.php b/wcfsetup/install/files/lib/system/WCFACP.class.php index a9a0f7c081..9abc708d46 100644 --- a/wcfsetup/install/files/lib/system/WCFACP.class.php +++ b/wcfsetup/install/files/lib/system/WCFACP.class.php @@ -3,7 +3,7 @@ namespace wcf\system; use wcf\acp\form\MasterPasswordForm; use wcf\acp\form\MasterPasswordInitForm; use wcf\system\application\ApplicationHandler; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\PackageCacheBuilder; use wcf\system\exception\AJAXException; use wcf\system\exception\PermissionDeniedException; use wcf\system\request\RouteHandler; @@ -130,11 +130,7 @@ class WCFACP extends WCF { protected function loadDefaultCacheResources() { parent::loadDefaultCacheResources(); - CacheHandler::getInstance()->addResource( - 'package', - WCF_DIR.'cache/cache.package.php', - 'wcf\system\cache\builder\PackageCacheBuilder' - ); + // TODO: Is this required anymore? } /** @@ -154,8 +150,7 @@ class WCFACP extends WCF { */ protected function getQuickAccessPackages() { $quickAccessPackages = array(); - $packages = CacheHandler::getInstance()->get('package'); - foreach ($packages['packages'] as $packageID => $package) { + foreach (PackageCacheBuilder::getInstance()->getData(array(), 'packages') as $packageID => $package) { if (!$package->isApplication) break; if ($package->package != 'com.woltlab.wcf') { $quickAccessPackages[] = $package; diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 6b0c2ee0a2..1d797d5833 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -5,7 +5,7 @@ use wcf\data\language\SetupLanguage; use wcf\data\package\installation\queue\PackageInstallationQueueEditor; use wcf\data\user\User; use wcf\data\user\UserAction; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\LanguageCacheBuilder; use wcf\system\database\util\SQLParser; use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; @@ -864,7 +864,7 @@ class WCFSetup extends WCF { LanguageFactory::getInstance()->makeDefault($language->languageID); // rebuild language cache - CacheHandler::getInstance()->clearResource('language'); + LanguageCacheBuilder::getInstance()->reset(); // go to next step $this->gotoNextStep('createUser'); diff --git a/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php b/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php index 87ea4e5c93..2f8b43a219 100644 --- a/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php +++ b/wcfsetup/install/files/lib/system/acl/ACLHandler.class.php @@ -6,7 +6,7 @@ use wcf\data\acl\option\ACLOption; use wcf\data\acl\option\ACLOptionList; use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\User; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\ACLOptionCategoryCacheBuilder; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; @@ -16,7 +16,7 @@ use wcf\system\WCF; * Handles ACL permissions. * * @author Alexander Ebert - * @copyright 2001-2011 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.acl @@ -116,13 +116,7 @@ class ACLHandler extends SingletonFactory { */ protected function init() { $this->availableObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.acl'); - - CacheHandler::getInstance()->addResource( - 'aclOptionCategory', - WCF_DIR.'cache/cache.aclOptionCategory.php', - 'wcf\system\cache\builder\ACLOptionCategoryCacheBuilder' - ); - $this->categories = CacheHandler::getInstance()->get('aclOptionCategory'); + $this->categories = ACLOptionCategoryCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php index 38ba521163..3816dee286 100644 --- a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php +++ b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php @@ -3,14 +3,14 @@ namespace wcf\system\application; use wcf\data\application\ApplicationAction; use wcf\data\application\ApplicationEditor; use wcf\data\application\ApplicationList; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\ApplicationCacheBuilder; use wcf\system\SingletonFactory; /** * Handles multi-application environments. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.application @@ -33,12 +33,7 @@ class ApplicationHandler extends SingletonFactory { * Initializes cache. */ protected function init() { - CacheHandler::getInstance()->addResource( - 'application', - WCF_DIR.'cache/cache.application.php', - 'wcf\system\cache\builder\ApplicationCacheBuilder' - ); - $this->cache = CacheHandler::getInstance()->get('application'); + $this->cache = ApplicationCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php index 9ab1be24bc..9b9ebf5c25 100644 --- a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php +++ b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php @@ -44,7 +44,7 @@ class CacheHandler extends SingletonFactory { } /** - * Flushed cache for given resource. + * Flush cache for given resource. * * @param wcf\system\cache\builder\ICacheBuilder $cacheBuilder * @param array $parameters @@ -54,6 +54,13 @@ class CacheHandler extends SingletonFactory { $this->getCacheSource()->flush($this->getCacheName($cacheBuilder), $useWildCard); } + /** + * Flushes the entire cache. + */ + public function flushAll() { + $this->getCacheSource()->flushAll(); + } + /** * Returns cached value for given resource, false if no cache exists. * diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php index f90b7792d8..9518ce0662 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php @@ -3,7 +3,7 @@ namespace wcf\system\cache\builder; use wcf\data\template\listener\TemplateListenerList; /** - * Caches the template listener code for a certain template in a certain environment. + * Caches the template listener code for a certain environment. * * @author Alexander Ebert * @copyright 2001-2013 WoltLab GmbH @@ -20,12 +20,15 @@ class TemplateListenerCodeCacheBuilder extends AbstractCacheBuilder { // get template codes for specified template $templateListenerList = new TemplateListenerList(); $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($parameters['environment'])); - $templateListenerList->getConditionBuilder()->add("template_listener.templateName = ?", array($parameters['templateName'])); $templateListenerList->readObjects(); $data = array(); foreach ($templateListenerList->getObjects() as $templateListener) { - $data[$templateListener->eventName][] = $templateListener->templateCode; + if (!isset($data[$templateListener->templateName])) { + $data[$templateListener->templateName] = array(); + } + + $data[$templateListener->templateName][$templateListener->eventName][] = $templateListener->templateCode; } return $data; diff --git a/wcfsetup/install/files/lib/system/category/CategoryHandler.class.php b/wcfsetup/install/files/lib/system/category/CategoryHandler.class.php index 4456a8b084..6e76794a59 100644 --- a/wcfsetup/install/files/lib/system/category/CategoryHandler.class.php +++ b/wcfsetup/install/files/lib/system/category/CategoryHandler.class.php @@ -4,7 +4,7 @@ use wcf\data\category\Category; use wcf\data\object\type\ObjectTypeCache; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectDecorator; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CategoryCacheBuilder; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; @@ -12,7 +12,7 @@ use wcf\system\SingletonFactory; * Handles the categories. * * @author Matthias Schmidt - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.category @@ -147,20 +147,15 @@ class CategoryHandler extends SingletonFactory { $this->objectTypeIDs[$objectType->objectTypeID] = $objectType->objectType; } - CacheHandler::getInstance()->addResource( - 'category', - WCF_DIR.'cache/cache.category.php', - 'wcf\system\cache\builder\CategoryCacheBuilder' - ); - $this->categories = CacheHandler::getInstance()->get('category', 'categories'); - $this->objectTypeCategoryIDs = CacheHandler::getInstance()->get('category', 'objectTypeCategoryIDs'); + $this->categories = CategoryCacheBuilder::getInstance()->getData(array(), 'categories'); + $this->objectTypeCategoryIDs = CategoryCacheBuilder::getInstance()->getData(array(), 'objectTypeCategoryIDs'); } /** * Reloads the category cache. */ public function reloadCache() { - CacheHandler::getInstance()->clearResource('category'); + CategoryCacheBuilder::getInstance()->reset(); $this->init(); } diff --git a/wcfsetup/install/files/lib/system/category/CategoryPermissionHandler.class.php b/wcfsetup/install/files/lib/system/category/CategoryPermissionHandler.class.php index 61e3b496a3..64995c1f9e 100644 --- a/wcfsetup/install/files/lib/system/category/CategoryPermissionHandler.class.php +++ b/wcfsetup/install/files/lib/system/category/CategoryPermissionHandler.class.php @@ -2,7 +2,7 @@ namespace wcf\system\category; use wcf\data\category\Category; use wcf\data\user\User; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CategoryACLOptionCacheBuilder; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -10,7 +10,7 @@ use wcf\system\WCF; * Handles the category permissions. * * @author Matthias Schmidt - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.category @@ -66,18 +66,13 @@ class CategoryPermissionHandler extends SingletonFactory { * @see wcf\system\SingletonFactory::init() */ protected function init() { - CacheHandler::getInstance()->addResource( - 'categoryACLOption', - WCF_DIR.'cache/cache.categoryACLOption.php', - 'wcf\system\cache\builder\CategoryACLOptionCacheBuilder' - ); - $this->categoryPermissions = CacheHandler::getInstance()->get('categoryACLOption'); + $this->categoryPermissions = CategoryACLOptionCacheBuilder::getInstance()->getData(); } /** * Resets the category permission cache. */ public function resetCache() { - CacheHandler::getInstance()->clearResource('categoryACLOption'); + CategoryACLOptionCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php b/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php deleted file mode 100644 index fa1e86d1c5..0000000000 --- a/wcfsetup/install/files/lib/system/cleanup/CleanupHandler.class.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cleanup - * @category Community Framework - */ -class CleanupHandler { - /** - * unique instance of CleanupHandler - * @var wcf\system\cleanup\CleanupHandler - */ - protected static $instance = null; - - /** - * cleanup adapter cache - * @var array - */ - protected $cache = null; - - /** - * Initializes cleanup handler. - */ - protected function __construct() { - $this->loadCache(); - } - - /** - * Prevents creating an additional instance. - */ - protected function __clone() {} - - /** - * Loads cleanup adapter cache. - */ - protected function loadCache() { - CacheHandler::getInstance()->addResource( - 'cleanupAdapter', - WCF_DIR.'cache/cache.cleanupAdapter.php', - 'wcf\system\cache\builder\CleanupAdapterCacheBuilder' - ); - $this->cache = CacheHandler::getInstance()->get('cleanupAdapter'); - } - - /** - * Prepares adapter execution - */ - public function execute() { - // remove all logged items older than 24 hours - $sql = "DELETE FROM wcf".WCF_N."_cleanup_log - WHERE deleteTime < ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - (TIME_NOW - 86400) - )); - - // loop through all available adapters - foreach ($this->cache['adapters'] as $objectType => $adapters) { - // determine if there are any items for current object type - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("objectType = ?", array($objectType)); - $conditions->add("packageID IN (?)", array($this->cache['objectTypes'][$objectType])); - - $sql = "SELECT objectID - FROM wcf".WCF_N."_cleanup_log - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - - $objectIDs = array(); - while ($row = $statement->fetchArray()) { - $objectIDs[] = $row['objectID']; - } - - if (!empty($objectIDs)) { - $this->executeAdapters($adapters, $objectIDs); - } - } - } - - /** - * Executes specific cleanup adapters. - * - * @param array $adapters - * @param array $objectIDs - */ - protected function executeAdapters(array $adapters, array $objectIDs) { - $sql = "UPDATE wcf".WCF_N."_cleanup_listener - SET lastUpdateTime = ? - WHERE listenerID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - - foreach ($adapters as $adapterData) { - // validate class - if (!class_exists($adapterData['className'])) { - throw new SystemException("unable to find class '".$adapterData['className']."'"); - } - - // validate interface - if (!(ClassUtil::isInstanceOf($adapterData['className'], 'wcf\system\cleanup\ICleanupAdapter'))) { - throw new SystemException("'".$adapterData['className']."' does not implement 'wcf\system\cleanup\ICleanupAdapter'"); - } - - $adapter = new $adapterData['className'](); - $adapter->execute($objectIDs); - - // update last time of execution - $statement->execute(array(TIME_NOW, $adapterData['listenerID'])); - } - } - - /** - * Returns an unique instance of CleanupHandler. - * - * @return wcf\system\cleanup\CleanupHandler - */ - public static function getInstance() { - if (self::$instance === null) { - // call loadInstance event - EventHandler::getInstance()->fireAction(__CLASS__, 'loadInstance'); - - if (self::$instance === null) { - self::$instance = new CleanupHandler(); - } - } - - return self::$instance; - } - - /** - * Registers deleted objects. - * - * @param string $objectType - * @param array $objectIDs - * @param integer $packageID - */ - public static function registerObjects($objectType, array $objectIDs, $packageID) { - $objectIDs = ArrayUtil::toIntegerArray($objectIDs); - $packageID = intval($packageID); - - // insert items - $sql = "INSERT INTO wcf".WCF_N."_cleanup_log - (packageID, objectType, objectID, deleteTime) - VALUES (?, ?, ?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - - foreach ($objectIDs as $objectID) { - $statement->execute(array( - $packageID, - $objectType, - $objectID, - TIME_NOW - )); - } - } -} diff --git a/wcfsetup/install/files/lib/system/cleanup/ICleanupAdapter.class.php b/wcfsetup/install/files/lib/system/cleanup/ICleanupAdapter.class.php deleted file mode 100644 index 883504383b..0000000000 --- a/wcfsetup/install/files/lib/system/cleanup/ICleanupAdapter.class.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cleanup - * @category Community Framework - */ -interface ICleanupAdapter { - /** - * Executes this adapter. - * - * @param array $objectIDs - */ - public function execute(array $objectIDs); -} diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 436039444e..16ddee5554 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -1,7 +1,8 @@ * @package com.woltlab.wcf * @subpackage system.clipboard @@ -57,12 +58,7 @@ class ClipboardHandler extends SingletonFactory { $this->cache['objectTypeNames'][$objectType->objectType] = $objectType->objectTypeID; } - CacheHandler::getInstance()->addResource( - 'clipboardPage', - WCF_DIR.'cache/cache.clipboardPage.php', - 'wcf\system\cache\builder\ClipboardPageCacheBuilder' - ); - $this->pageCache = CacheHandler::getInstance()->get('clipboardPage'); + $this->pageCache = ClipboardPageCacheBuilder::getInstance()->getData(); } /** @@ -71,12 +67,7 @@ class ClipboardHandler extends SingletonFactory { protected function loadActionCache() { if ($this->actionCache !== null) return; - CacheHandler::getInstance()->addResource( - 'clipboardAction', - WCF_DIR.'cache/cache.clipboardAction.php', - 'wcf\system\cache\builder\ClipboardActionCacheBuilder' - ); - $this->actionCache = CacheHandler::getInstance()->get('clipboardAction'); + $this->actionCache = ClipboardActionCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index f7a8ba0767..de6fb7466e 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -3,7 +3,7 @@ namespace wcf\system\cronjob; use wcf\data\cronjob\log\CronjobLogEditor; use wcf\data\cronjob\Cronjob; use wcf\data\cronjob\CronjobEditor; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\CronjobCacheBuilder; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -13,7 +13,7 @@ use wcf\util\ClassUtil; * Provides functions to execute cronjobs. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.cronjob @@ -204,18 +204,13 @@ class CronjobScheduler extends SingletonFactory { * Loads the cached data for cronjob execution. */ protected function loadCache() { - CacheHandler::getInstance()->addResource( - 'cronjob', - WCF_DIR.'cache/cache.cronjob.php', - 'wcf\system\cache\builder\CronjobCacheBuilder' - ); - $this->cache = CacheHandler::getInstance()->get('cronjob'); + $this->cache = CronjobCacheBuilder::getInstance()->getData(); } /** * Clears the cronjob data cache. */ public static function clearCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.cronjob.php'); + CronjobCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php index 0cf62140b7..9788f21af0 100644 --- a/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php @@ -1,7 +1,7 @@ * @package com.woltlab.wcf * @subpackage system.cronjob @@ -66,7 +66,7 @@ class RefreshSearchRobotsCronjob implements ICronjob { } // clear spider cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.spider.php'); + SpiderCacheBuilder::getInstance()->reset(); } // delete tmp file diff --git a/wcfsetup/install/files/lib/system/event/EventHandler.class.php b/wcfsetup/install/files/lib/system/event/EventHandler.class.php index 7bdc71ae8e..4be629151a 100644 --- a/wcfsetup/install/files/lib/system/event/EventHandler.class.php +++ b/wcfsetup/install/files/lib/system/event/EventHandler.class.php @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.event @@ -51,12 +51,7 @@ class EventHandler extends SingletonFactory { */ protected function loadActions() { $environment = (class_exists('wcf\system\WCFACP', false) ? 'admin' : 'user'); - CacheHandler::getInstance()->addResource( - 'eventListener', - WCF_DIR.'cache/cache.eventListener.php', - 'wcf\system\cache\builder\EventListenerCacheBuilder' - ); - $cache = CacheHandler::getInstance()->get('eventListener'); + $cache = EventListenerCacheBuilder::getInstance()->getData(); if (isset($cache['actions'][$environment])) { $this->actions = $cache['actions'][$environment]; diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index f25adb7000..ffdc78175c 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -2,7 +2,7 @@ namespace wcf\system\language; use wcf\data\language\Language; use wcf\data\language\LanguageEditor; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\LanguageCacheBuilder; use wcf\system\template\TemplateScriptingCompiler; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -11,7 +11,7 @@ use wcf\system\WCF; * Handles language related functions. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.language @@ -215,13 +215,7 @@ class LanguageFactory extends SingletonFactory { */ protected function loadCache() { if (defined('WCF_N')) { - CacheHandler::getInstance()->addResource( - 'language', - WCF_DIR.'cache/cache.language.php', - 'wcf\system\cache\builder\LanguageCacheBuilder' - ); - - $this->cache = CacheHandler::getInstance()->get('language'); + $this->cache = LanguageCacheBuilder::getInstance()->getData(); } } @@ -229,7 +223,7 @@ class LanguageFactory extends SingletonFactory { * Clears languages cache. */ public function clearCache() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.language.php'); + LanguageCacheBuilder::getInstance()->reset(); } /** diff --git a/wcfsetup/install/files/lib/system/menu/acp/ACPMenu.class.php b/wcfsetup/install/files/lib/system/menu/acp/ACPMenu.class.php index a3451fd2f1..1d051c62bb 100644 --- a/wcfsetup/install/files/lib/system/menu/acp/ACPMenu.class.php +++ b/wcfsetup/install/files/lib/system/menu/acp/ACPMenu.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.menu.acp @@ -24,11 +24,6 @@ class ACPMenu extends TreeMenu { return; } - CacheHandler::getInstance()->addResource( - 'acpMenu', - WCF_DIR.'cache/cache.acpMenu.php', - 'wcf\system\cache\builder\ACPMenuCacheBuilder' - ); - $this->menuItems = CacheHandler::getInstance()->get('acpMenu'); + $this->menuItems = ACPMenuCacheBuilder::getInstance()->getData(); } } diff --git a/wcfsetup/install/files/lib/system/menu/page/PageMenu.class.php b/wcfsetup/install/files/lib/system/menu/page/PageMenu.class.php index f0b440975d..714aad0fe4 100644 --- a/wcfsetup/install/files/lib/system/menu/page/PageMenu.class.php +++ b/wcfsetup/install/files/lib/system/menu/page/PageMenu.class.php @@ -1,7 +1,7 @@ addResource( - 'pageMenu', - WCF_DIR.'cache/cache.pageMenu.php', - 'wcf\system\cache\builder\PageMenuCacheBuilder' - ); - $this->menuItems = CacheHandler::getInstance()->get('pageMenu'); + $this->menuItems = PageMenuCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/option/OptionHandler.class.php b/wcfsetup/install/files/lib/system/option/OptionHandler.class.php index b2acaa5d2d..6cc683d1f4 100644 --- a/wcfsetup/install/files/lib/system/option/OptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionHandler.class.php @@ -3,7 +3,6 @@ namespace wcf\system\option; use wcf\data\option\category\OptionCategory; use wcf\data\option\Option; use wcf\system\application\ApplicationHandler; -use wcf\system\cache\CacheHandler; use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\language\I18nHandler; @@ -15,7 +14,7 @@ use wcf\util\StringUtil; * Handles options. * * @author Alexander Ebert - * @copyright 2001-2011 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.option @@ -28,12 +27,6 @@ class OptionHandler implements IOptionHandler { */ protected $abbreviations = null; - /** - * cache name - * @var string - */ - public $cacheName = ''; - /** * cache class name * @var string @@ -115,8 +108,7 @@ class OptionHandler implements IOptionHandler { /** * @see wcf\system\option\IOptionHandler::__construct() */ - public function __construct($cacheName, $cacheClass, $supportI18n, $languageItemPattern = '', $categoryName = '') { - $this->cacheName = $cacheName; + public function __construct($cacheClass, $supportI18n, $languageItemPattern = '', $categoryName = '') { $this->cacheClass = $cacheClass; $this->categoryName = $categoryName; $this->languageItemPattern = $languageItemPattern; @@ -395,17 +387,13 @@ class OptionHandler implements IOptionHandler { * Gets all options and option categories from cache. */ protected function readCache() { - CacheHandler::getInstance()->addResource( - $this->cacheName, - WCF_DIR.'cache/cache.'.$this->cacheName.'.php', - $this->cacheClass - ); + $cache = call_user_func(array($this->cacheClass, 'getInstance')); // get cache contents - $this->cachedCategories = CacheHandler::getInstance()->get($this->cacheName, 'categories'); - $this->cachedOptions = CacheHandler::getInstance()->get($this->cacheName, 'options'); - $this->cachedCategoryStructure = CacheHandler::getInstance()->get($this->cacheName, 'categoryStructure'); - $this->cachedOptionToCategories = CacheHandler::getInstance()->get($this->cacheName, 'optionToCategories'); + $this->cachedCategories = $cache->getData(array(), 'categories'); + $this->cachedOptions = $cache->getData(array(), 'options'); + $this->cachedCategoryStructure = $cache->getData(array(), 'categoryStructure'); + $this->cachedOptionToCategories = $cache->getData(array(), 'optionToCategories'); } /** diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index daff3c45a9..aab03e29ba 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -1,5 +1,9 @@ * @package com.woltlab.wcf * @subpackage system.package @@ -154,7 +158,7 @@ class PackageInstallationDispatcher { // remove all cache files after WCFSetup if (!PACKAGE_ID) { - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.*.php'); + CacheHandler::getInstance()->flushAll(); } // rebuild application paths @@ -163,7 +167,8 @@ class PackageInstallationDispatcher { } // remove template listener cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache/templateListener/', '*.php'); + TemplateListenerCacheBuilder::getInstance()->reset(); + TemplateListenerCodeCacheBuilder::getInstance()->reset(); // reset language cache LanguageFactory::getInstance()->clearCache(); @@ -758,7 +763,7 @@ class PackageInstallationDispatcher { LanguageEditor::deleteLanguageFiles(); // reset all caches - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', '*'); + CacheHandler::getInstance()->flushAll(); } /** diff --git a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php index 659f30a04b..5463d54bc5 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php @@ -6,6 +6,7 @@ use wcf\data\package\Package; use wcf\data\package\PackageEditor; use wcf\data\package\PackageList; use wcf\system\application\ApplicationHandler; +use wcf\system\cache\builder\PackageCacheBuilder; use wcf\system\cache\CacheHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\SystemException; @@ -21,7 +22,7 @@ use wcf\util\FileUtil; * Handles the whole uninstallation process. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.package @@ -73,19 +74,8 @@ class PackageUninstallationDispatcher extends PackageInstallationDispatcher { // update options.inc.php if uninstallation is completed OptionEditor::resetCache(); - // force removal of all cache files - $sql = "SELECT packageDir - FROM wcf".WCF_N."_package - WHERE isApplication = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array(1)); - while ($row = $statement->fetchArray()) { - $dir = FileUtil::getRealPath(WCF_DIR.$row['packageDir']); - CacheHandler::getInstance()->clear($dir.'cache/', 'cache.*.php'); - } - - // remove template listener cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache/templateListener/', '*.php'); + // clear cache + CacheHandler::getInstance()->flushAll(); // reset language cache LanguageFactory::getInstance()->clearCache(); @@ -138,7 +128,7 @@ class PackageUninstallationDispatcher extends PackageInstallationDispatcher { )); // reset package cache - CacheHandler::getInstance()->clearResource('package'); + PackageCacheBuilder::getInstance()->reset(); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php index 90776f4f38..55d735c6f6 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -76,6 +76,6 @@ class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInsta * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup() */ protected function cleanup() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.acpSearchProvider.php'); + ACPSearchProviderCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php index 12ab9dce05..78ae3f5875 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -67,6 +67,6 @@ class CoreObjectPackageInstallationPlugin extends AbstractXMLPackageInstallation * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup() */ protected function cleanup() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.coreObject.php'); + CoreObjectCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php index 479bca67a1..26ce6b6fda 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -98,6 +98,6 @@ class EventListenerPackageInstallationPlugin extends AbstractXMLPackageInstallat parent::uninstall(); // clear cache immediately - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.eventListener.php'); + EventListenerCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php index 70d9df0295..6b25960d9b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php @@ -8,7 +8,7 @@ use wcf\util\FileUtil; * Executes individual PHP scripts during installation. * * @author Benjamin Kunz - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -34,7 +34,7 @@ class ScriptPackageInstallationPlugin extends AbstractPackageInstallationPlugin $path = FileUtil::getRealPath(WCF_DIR.$packageDir); // reset WCF cache - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', '*.php'); + CacheHandler::getInstance()->flushAll(); // run script $this->run($path.$this->instruction['value']); diff --git a/wcfsetup/install/files/lib/system/package/plugin/SitemapPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/SitemapPackageInstallationPlugin.class.php index 97d7af2635..c740716b85 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/SitemapPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/SitemapPackageInstallationPlugin.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -72,6 +72,6 @@ class SitemapPackageInstallationPlugin extends AbstractXMLPackageInstallationPlu * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup() */ protected function cleanup() { - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.sitemap.php'); + SitemapCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php index 8ed707c80d..afa29925b7 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php @@ -1,5 +1,8 @@ * @package com.woltlab.wcf * @subpackage system.package.plugin @@ -84,7 +87,7 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal */ protected function cleanup() { // clear cache immediately - CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.templateListener.php'); - CacheHandler::getInstance()->clear(WCF_DIR.'cache/templateListener', '*.php'); + TemplateListenerCacheBuilder::getInstance()->reset(); + TemplateListenerCodeCacheBuilder::getInstance()->reset(); } } diff --git a/wcfsetup/install/files/lib/system/search/acp/ACPSearchHandler.class.php b/wcfsetup/install/files/lib/system/search/acp/ACPSearchHandler.class.php index f67c3fc19f..c43a1e03ad 100644 --- a/wcfsetup/install/files/lib/system/search/acp/ACPSearchHandler.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/ACPSearchHandler.class.php @@ -1,7 +1,7 @@ * @package com.woltlab.wcf * @subpackage system.search.acp @@ -33,13 +33,7 @@ class ACPSearchHandler extends SingletonFactory { * @see wcf\system\SingletonFactory::init() */ protected function init() { - CacheHandler::getInstance()->addResource( - 'acpSearchProvider', - WCF_DIR.'cache/cache.acpSearchProvider.php', - 'wcf\system\cache\builder\ACPSearchProviderCacheBuilder' - ); - - $this->cache = CacheHandler::getInstance()->get('acpSearchProvider'); + $this->cache = ACPSearchProviderCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 00108f2e8a..dc8f22de46 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -2,7 +2,7 @@ namespace wcf\system\session; use wcf\data\user\User; use wcf\page\ITrackablePage; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\UserGroupPermissionCacheBuilder; use wcf\system\exception\PermissionDeniedException; use wcf\system\request\RequestHandler; use wcf\system\user\authentication\UserAuthenticationFactory; @@ -16,7 +16,7 @@ use wcf\util\UserUtil; * Handles sessions. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.session @@ -405,19 +405,8 @@ class SessionHandler extends SingletonFactory { $groupIDs = $this->user->getGroupIDs(); } - $groups = implode(',', $groupIDs); - $groupsFileName = StringUtil::getHash($groups); - - // register cache resource - $cacheName = 'userGroup-'.$groups; - CacheHandler::getInstance()->addResource( - $cacheName, - WCF_DIR.'cache/cache.userGroup-'.$groupsFileName.'.php', - 'wcf\system\cache\builder\UserGroupPermissionCacheBuilder' - ); - // get group data from cache - $this->groupData = CacheHandler::getInstance()->get($cacheName); + $this->groupData = UserGroupPermissionCacheBuilder::getInstance()->getData($groupIDs); if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $groups) { $this->groupData = array(); } diff --git a/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php b/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php index 92e54e14dd..f94788917a 100644 --- a/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php +++ b/wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage sitemap.sitemap @@ -25,12 +25,7 @@ class SitemapHandler extends SingletonFactory { * @see wcf\system\SingletonFactory::init() */ protected function init() { - CacheHandler::getInstance()->addResource( - 'sitemap', - WCF_DIR.'cache/cache.sitemap.php', - 'wcf\system\cache\builder\SitemapCacheBuilder' - ); - $this->cache = CacheHandler::getInstance()->get('sitemap'); + $this->cache = SitemapCacheBuilder::getInstance()->get('sitemap'); } /** diff --git a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php index 79f144bcca..c6943436bc 100644 --- a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php @@ -2,7 +2,7 @@ namespace wcf\system\style; use wcf\data\style\ActiveStyle; use wcf\data\style\Style; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\StyleCacheBuilder; use wcf\system\exception\SystemException; use wcf\system\request\RequestHandler; use wcf\system\SingletonFactory; @@ -12,7 +12,7 @@ use wcf\system\WCF; * Handles styles. * * @author Marcel Werk - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.style @@ -36,12 +36,7 @@ class StyleHandler extends SingletonFactory { */ protected function init() { // load cache - CacheHandler::getInstance()->addResource( - 'style', - WCF_DIR.'cache/cache.style.php', - 'wcf\system\cache\builder\StyleCacheBuilder' - ); - $this->cache = CacheHandler::getInstance()->get('style'); + $this->cache = StyleCacheBuilder::getInstance()->getData(); } /** diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index 7103d89f8e..07290558f4 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -1,6 +1,8 @@ hasTemplateListeners($templateName)) { - $this->loadTemplateListenerCode($templateName); - - $templateListenerCache = WCF_DIR.'cache/templateListener/'.$this->environment.'-'.$templateName.'.php'; - $templateListenerCacheMTime = @filemtime($templateListenerCache); - - return !($sourceMTime >= $templateListenerCacheMTime); - } - return true; } } @@ -641,12 +639,7 @@ class TemplateEngine extends SingletonFactory { * Loads cached template group information. */ protected function loadTemplateGroupCache() { - CacheHandler::getInstance()->addResource( - 'templateGroup', - WCF_DIR.'cache/cache.templateGroup.php', - 'wcf\system\cache\builder\TemplateGroupCacheBuilder' - ); - $this->templateGroupCache = CacheHandler::getInstance()->get('templateGroup'); + $this->templateGroupCache = TemplateGroupCacheBuilder::getInstance()->getData(); } /** @@ -719,14 +712,7 @@ class TemplateEngine extends SingletonFactory { * Loads all available template listeners. */ protected function loadTemplateListeners() { - $cacheName = 'templateListener-'.$this->environment; - CacheHandler::getInstance()->addResource( - $cacheName, - WCF_DIR.'cache/cache.'.$cacheName.'.php', - 'wcf\system\cache\builder\TemplateListenerCacheBuilder' - ); - - $this->templateListeners = CacheHandler::getInstance()->get($cacheName); + $this->templateListeners = TemplateListenerCacheBuilder::getInstance()->getData(array('environment' => $this->environment)); } /** @@ -745,21 +731,13 @@ class TemplateEngine extends SingletonFactory { } /** - * Loads template code for specified template. - * - * @param string $templateName + * Loads template listener code. */ - protected function loadTemplateListenerCode($templateName) { - // cache was already loaded - if (!isset($this->templateListeners[$templateName]) || !empty($this->templateListeners[$templateName])) return; - - $cacheName = $this->environment.'-'.$templateName; - CacheHandler::getInstance()->addResource( - $cacheName, - WCF_DIR.'cache/templateListener/'.$cacheName.'.php', - 'wcf\system\cache\builder\TemplateListenerCodeCacheBuilder' - ); - $this->templateListeners[$templateName] = CacheHandler::getInstance()->get($cacheName); + protected function loadTemplateListenerCode() { + if (!$this->templateListenersLoaded) { + $this->templateListeners = TemplateListenerCodeCacheBuilder::getInstance()->getData(array('environment' => $this->environment)); + $this->templateListenersLoaded = true; + } } /** @@ -770,7 +748,7 @@ class TemplateEngine extends SingletonFactory { * @return string */ public function getTemplateListenerCode($templateName, $eventName) { - $this->loadTemplateListenerCode($templateName); + $this->loadTemplateListenerCode(); if (isset($this->templateListeners[$templateName][$eventName])) { return implode("\n", $this->templateListeners[$templateName][$eventName]); diff --git a/wcfsetup/install/files/lib/system/version/VersionHandler.class.php b/wcfsetup/install/files/lib/system/version/VersionHandler.class.php index a01decd83c..0789323e84 100644 --- a/wcfsetup/install/files/lib/system/version/VersionHandler.class.php +++ b/wcfsetup/install/files/lib/system/version/VersionHandler.class.php @@ -2,14 +2,14 @@ namespace wcf\system\version; use wcf\data\object\type\ObjectTypeCache; use wcf\data\VersionableDatabaseObject; -use wcf\system\cache\CacheHandler; +use wcf\system\cache\builder\VersionCacheBuilder; use wcf\system\SingletonFactory; /** * Handles versions of DatabaseObjects. * * @author Jeffrey Reichardt - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.version @@ -107,18 +107,16 @@ class VersionHandler extends SingletonFactory { foreach ($this->objectTypes as $objectType) { $this->objectTypeIDs[$objectType->objectTypeID] = $objectType->objectType; } - - $cacheName = 'version'; - CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\builder\VersionCacheBuilder'); - $this->versions = CacheHandler::getInstance()->get($cacheName, 'versions'); - $this->versionIDs = CacheHandler::getInstance()->get($cacheName, 'versionIDs'); + + $this->versions = VersionCacheBuilder::getInstance()->getData(array(), 'versions'); + $this->versionIDs = VersionCacheBuilder::getInstance()->getData(array(), 'versionIDs'); } /** * Reloads the version cache. */ public function reloadCache() { - CacheHandler::getInstance()->clearResource('version'); + VersionCacheBuilder::getInstance()->reset(); $this->init(); } diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index cb71a40c7b..eb6535581e 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -133,25 +133,6 @@ CREATE TABLE wcf1_category ( additionalData TEXT ); -DROP TABLE IF EXISTS wcf1_cleanup_listener; -CREATE TABLE wcf1_cleanup_listener ( - listenerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, - packageID INT(10) NOT NULL, - className VARCHAR(255) NOT NULL DEFAULT '', - objectType VARCHAR(255) NOT NULL DEFAULT '', - lastUpdateTime INT(10) NOT NULL DEFAULT 0, - UNIQUE KEY (className, packageID) -); - -DROP TABLE IF EXISTS wcf1_cleanup_log; -CREATE TABLE wcf1_cleanup_log ( - packageID INT(10) NOT NULL DEFAULT 0, - objectType VARCHAR(255) NOT NULL DEFAULT '', - objectID INT(10) NOT NULL DEFAULT 0, - deleteTime INT(10) NOT NULL DEFAULT 0, - KEY objectType (objectType) -); - DROP TABLE IF EXISTS wcf1_clipboard_action; CREATE TABLE wcf1_clipboard_action ( actionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, @@ -794,10 +775,6 @@ ALTER TABLE wcf1_application ADD FOREIGN KEY (packageID) REFERENCES wcf1_package ALTER TABLE wcf1_category ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE; -ALTER TABLE wcf1_cleanup_listener ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; - -ALTER TABLE wcf1_cleanup_log ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; - ALTER TABLE wcf1_clipboard_action ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; ALTER TABLE wcf1_clipboard_item ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE; -- 2.20.1