From 07356d6b969b50868cd3762b6d18c6cc6c5c8d30 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 4 Feb 2013 00:58:22 +0100 Subject: [PATCH] Major overhaul of caching system (work in progress) See #1124 --- .../ACLOptionCategoryCacheBuilder.class.php | 8 +-- .../builder/ACPMenuCacheBuilder.class.php | 8 +-- .../ACPSearchProviderCacheBuilder.class.php | 8 +-- .../builder/ApplicationCacheBuilder.class.php | 8 +-- .../CategoryACLOptionCacheBuilder.class.php | 8 +-- .../builder/CategoryCacheBuilder.class.php | 8 +-- .../CleanupAdapterCacheBuilder.class.php | 45 ------------- .../ClipboardActionCacheBuilder.class.php | 8 +-- .../ClipboardPageCacheBuilder.class.php | 8 +-- .../builder/CoreObjectCacheBuilder.class.php | 8 +-- .../builder/CronjobCacheBuilder.class.php | 8 +-- .../EventListenerCacheBuilder.class.php | 8 +-- .../builder/LanguageCacheBuilder.class.php | 11 ++-- .../builder/ObjectTypeCacheBuilder.class.php | 8 +-- .../builder/OptionCacheBuilder.class.php | 64 +++++++------------ .../builder/PackageCacheBuilder.class.php | 8 +-- .../builder/PageMenuCacheBuilder.class.php | 8 +-- .../builder/SitemapCacheBuilder.class.php | 8 +-- .../builder/SpiderCacheBuilder.class.php | 8 +-- .../cache/builder/StyleCacheBuilder.class.php | 8 +-- .../builder/TemplateCacheBuilder.class.php | 43 ------------- .../TemplateGroupCacheBuilder.class.php | 8 +-- .../TemplateListenerCacheBuilder.class.php | 12 ++-- ...TemplateListenerCodeCacheBuilder.class.php | 14 ++-- .../builder/UserGroupCacheBuilder.class.php | 8 +-- .../UserGroupOptionCacheBuilder.class.php | 24 +++++++ .../UserGroupPermissionCacheBuilder.class.php | 13 ++-- .../builder/UserOptionCacheBuilder.class.php | 24 +++++++ .../builder/VersionCacheBuilder.class.php | 8 +-- 29 files changed, 173 insertions(+), 237 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php delete mode 100644 wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php create mode 100644 wcfsetup/install/files/lib/system/cache/builder/UserGroupOptionCacheBuilder.class.php create mode 100644 wcfsetup/install/files/lib/system/cache/builder/UserOptionCacheBuilder.class.php diff --git a/wcfsetup/install/files/lib/system/cache/builder/ACLOptionCategoryCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ACLOptionCategoryCacheBuilder.class.php index 4b6bf9df59..d3d156533a 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ACLOptionCategoryCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ACLOptionCategoryCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\acl\option\category\ACLOptionCategoryList; * Caches the acl categories for a certain package. * * @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.cache.builder * @category Community Framework */ -class ACLOptionCategoryCacheBuilder implements ICacheBuilder { +class ACLOptionCategoryCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $list = new ACLOptionCategoryList(); $list->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php index 829971ac14..edcbf5b4b6 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php @@ -11,13 +11,13 @@ use wcf\system\request\LinkHandler; * Caches the ACP menu items. * * @author Matthias Schmidt, Marcel Werk - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.cache.builder * @category Community Framework */ -class ACPMenuCacheBuilder implements ICacheBuilder { +class ACPMenuCacheBuilder extends AbstractCacheBuilder { /** * list of option categories which directly contain options * @var array @@ -31,9 +31,9 @@ class ACPMenuCacheBuilder implements ICacheBuilder { protected $categoryStructure = array(); /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array(); // get "real" menu items diff --git a/wcfsetup/install/files/lib/system/cache/builder/ACPSearchProviderCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ACPSearchProviderCacheBuilder.class.php index 1ceefce60d..222b7c0f78 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ACPSearchProviderCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ACPSearchProviderCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\acp\search\provider\ACPSearchProviderList; * Caches the ACP search providers. * * @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.cache.builder * @category Community Framework */ -class ACPSearchProviderCacheBuilder implements ICacheBuilder { +class ACPSearchProviderCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $providerList = new ACPSearchProviderList(); $providerList->sqlOrderBy = "acp_search_provider.showOrder ASC"; $providerList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php index d5cefaa718..96bc910565 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php @@ -8,17 +8,17 @@ use wcf\data\package\PackageList; * Caches 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 system.cache.builder * @category Community Framework */ -class ApplicationCacheBuilder implements ICacheBuilder { +class ApplicationCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'abbreviation' => array(), 'application' => array(), diff --git a/wcfsetup/install/files/lib/system/cache/builder/CategoryACLOptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CategoryACLOptionCacheBuilder.class.php index b99d6e135d..30c5e04a44 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/CategoryACLOptionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/CategoryACLOptionCacheBuilder.class.php @@ -7,17 +7,17 @@ use wcf\system\category\CategoryHandler; * Caches the acl options of 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.cache.builder * @category Community Framework */ -class CategoryACLOptionCacheBuilder implements ICacheBuilder { +class CategoryACLOptionCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array(); foreach (CategoryHandler::getInstance()->getCategories() as $objectTypeName => $categories) { $objectType = CategoryHandler::getInstance()->getObjectTypeByName($objectTypeName); diff --git a/wcfsetup/install/files/lib/system/cache/builder/CategoryCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CategoryCacheBuilder.class.php index 2616eeaf32..e272e362c8 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/CategoryCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/CategoryCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\category\CategoryList; * Caches the categories for the active application. * * @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.cache.builder * @category Community Framework */ -class CategoryCacheBuilder implements ICacheBuilder { +class CategoryCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $list = new CategoryList(); $list->sqlSelects = "object_type.objectType"; $list->sqlJoins = "LEFT JOIN wcf".WCF_N."_object_type object_type ON (object_type.objectTypeID = category.objectTypeID)"; diff --git a/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php deleted file mode 100644 index c8ae3cedd9..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CleanupAdapterCacheBuilder implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData(array $cacheResource) { - $data = array( - 'adapters' => array(), - 'objectTypes' => array(), - 'packageIDs' => array() - ); - - $sql = "SELECT listener.*, package.packageDir - FROM wcf".WCF_N."_cleanup_listener listener - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = listener.packageID)"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - if (!is_array($data['adapters'][$row['objectType']])) $data['adapters'][$row['objectType']] = array(); - $data['adapters'][$row['objectType']][] = $row; - - if (!is_array($data['objectTypes'][$row['objectType']])) $data['objectTypes'][$row['objectType']] = array(); - $data['objectTypes'][$row['objectType']][] = $row['packageID']; - } - - $data['objectTypes'] = array_unique($data['objectTypes']); - $data['packageIDs'] = array_unique($data['packageIDs']); - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php index 53550d6ec5..7c613ea0d1 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\clipboard\action\ClipboardActionList; * Caches clipboard actions. * * @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.cache.builder * @category Community Framework */ -class ClipboardActionCacheBuilder implements ICacheBuilder { +class ClipboardActionCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $actionList = new ClipboardActionList(); $actionList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php index eeede22ee1..3d1c8be374 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\system\WCF; * Caches clipboard pages. * * @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.cache.builder * @category Community Framework */ -class ClipboardPageCacheBuilder implements ICacheBuilder { +class ClipboardPageCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $sql = "SELECT pageClassName, actionID FROM wcf".WCF_N."_clipboard_page"; $statement = WCF::getDB()->prepareStatement($sql); diff --git a/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php index 36ae1b99c1..4af26d9004 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\core\object\CoreObjectList; * Caches the core objects. * * @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.cache.builder * @category Community Framework */ -class CoreObjectCacheBuilder implements ICacheBuilder { +class CoreObjectCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array(); $coreObjectList = new CoreObjectList(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php index f4dd35be82..1df0ffd9dd 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\system\WCF; * Caches cronjob information. * * @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.cache.builder * @category Community Framework */ -class CronjobCacheBuilder implements ICacheBuilder { +class CronjobCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $sql = "SELECT MIN(nextExec) AS nextExec, MIN(afterNextExec) AS afterNextExec FROM wcf".WCF_N."_cronjob"; diff --git a/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php index 7768ca1b97..f202e77d3e 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php @@ -7,17 +7,17 @@ use wcf\system\WCF; * Caches the event listeners. * * @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.cache.builder * @category Community Framework */ -class EventListenerCacheBuilder implements ICacheBuilder { +class EventListenerCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'actions' => array('user' => array(), 'admin' => array()), 'inheritedActions' => array('user' => array(), 'admin' => array()) diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php index 5dbbd6ab2d..1a90d52ad1 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -6,21 +6,20 @@ use wcf\data\DatabaseObject; use wcf\system\WCF; /** - * Caches languages, language to packages relation, package to languages relation - * and the id of the default language. + * Caches languages and the id of the default language. * * @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.cache.builder * @category Community Framework */ -class LanguageCacheBuilder implements ICacheBuilder { +class LanguageCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'codes' => array(), 'countryCodes' => array(), diff --git a/wcfsetup/install/files/lib/system/cache/builder/ObjectTypeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ObjectTypeCacheBuilder.class.php index 6ba7adca8c..7fd7c5f169 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ObjectTypeCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ObjectTypeCacheBuilder.class.php @@ -8,17 +8,17 @@ use wcf\system\WCF; * Caches object types and object type definitions. * * @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.cache.builder * @category Community Framework */ -class ObjectTypeCacheBuilder implements ICacheBuilder { +class ObjectTypeCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'categories' => array(), 'definitions' => array(), diff --git a/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php index 8239b3e5c4..d89358db9c 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php @@ -6,36 +6,32 @@ use wcf\system\Regex; use wcf\system\WCF; /** - * Caches the options and option categories + * Caches options and option categories * * @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.cache.builder * @category Community Framework */ -class OptionCacheBuilder implements ICacheBuilder { +class OptionCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * option class name + * @var string */ - public function getData(array $cacheResource) { - $tableName = ''; - $type = $cacheResource['cache']; - - $regEx = new Regex('((?:^|[A-Z])[a-z]+)'); - $regEx->match($cacheResource['cache'], true); - $matches = $regEx->getMatches(); - if (isset($matches[1])) { - for ($i = 0, $length = count($matches[1]); $i < $length; $i++) { - if (!empty($tableName)) { - $tableName .= '_'; - } - - $tableName .= strtolower($matches[1][$i]); - } - } - + protected $optionClassName = 'wcf\data\option\Option'; + + /** + * database table name + * @var string + */ + protected $tableName = 'option'; + + /** + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() + */ + public function rebuild(array $parameters) { $data = array( 'categories' => array(), 'options' => array(), @@ -46,7 +42,7 @@ class OptionCacheBuilder implements ICacheBuilder { // option categories // get all option categories and sort categories by priority $sql = "SELECT categoryName, categoryID - FROM wcf".WCF_N."_".$tableName."_category"; + FROM wcf".WCF_N."_".$this->tableName."_category"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); $optionCategories = array(); @@ -60,7 +56,7 @@ class OptionCacheBuilder implements ICacheBuilder { $conditions->add("categoryID IN (?)", array($optionCategories)); $sql = "SELECT option_category.*, package.packageDir - FROM wcf".WCF_N."_".$tableName."_category option_category + FROM wcf".WCF_N."_".$this->tableName."_category option_category LEFT JOIN wcf".WCF_N."_package package ON (package.packageID = option_category.packageID) ".$conditions." @@ -81,7 +77,7 @@ class OptionCacheBuilder implements ICacheBuilder { // get all options and sort options by priority $optionIDs = array(); $sql = "SELECT optionName, optionID - FROM wcf".WCF_N."_".$tableName; + FROM wcf".WCF_N."_".$this->tableName; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); while ($row = $statement->fetchArray()) { @@ -89,33 +85,19 @@ class OptionCacheBuilder implements ICacheBuilder { } if (!empty($optionIDs)) { - // get option class from type - $className = 'wcf\data\option\Option'; - if (!empty($type)) { - // strip trailing underscore - preg_match_all('~((?:^|[A-Z])[a-z]+)~', $type, $matches); - - if (isset($matches[1])) { - $className = 'wcf\data\\'; - for ($i = 0, $length = count($matches[1]); $i < $length; $i++) { - $className .= strtolower($matches[1][$i] . '\\'); - } - $className .= ucfirst($type); - } - } - // get needed options $conditions = new PreparedStatementConditionBuilder(); $conditions->add("optionID IN (?)", array($optionIDs)); $sql = "SELECT * - FROM wcf".WCF_N."_".$tableName." + FROM wcf".WCF_N."_".$this->tableName." ".$conditions." ORDER BY showOrder ASC"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); + $optionClassName = $this->optionClassName; while ($row = $statement->fetchArray()) { - $data['options'][$row['optionName']] = new $className(null, $row); + $data['options'][$row['optionName']] = new $optionClassName(null, $row); if (!isset($data['optionToCategories'][$row['categoryName']])) { $data['optionToCategories'][$row['categoryName']] = array(); } diff --git a/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php index 42a71db69c..61b6208977 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\package\PackageList; * Caches all installed packages. * * @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.cache.builder * @category Community Framework */ -class PackageCacheBuilder implements ICacheBuilder { +class PackageCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'packages' => array(), 'packageIDs' => array() diff --git a/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php index 3664a08347..29503a1b05 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\page\menu\item\PageMenuItemList; * Caches the page menu items. * * @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.cache.builder * @category Community Framework */ -class PageMenuCacheBuilder implements ICacheBuilder { +class PageMenuCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array(); $menuItemList = new PageMenuItemList(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/SitemapCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/SitemapCacheBuilder.class.php index 53fb8b7f6f..505b8d37d4 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/SitemapCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/SitemapCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\sitemap\SitemapList; * Caches sitemap structure. * * @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.cache.builder * @category Community Framework */ -class SitemapCacheBuilder implements ICacheBuilder { +class SitemapCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $sitemapList = new SitemapList(); $sitemapList->sqlOrderBy = "sitemap.showOrder ASC"; $sitemapList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php index b3967f3619..6d765d4b2d 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\spider\SpiderList; * Caches the list of search engine spiders. * * @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.cache.builder * @category Community Framework */ -class SpiderCacheBuilder implements ICacheBuilder { +class SpiderCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $spiderList = new SpiderList(); $spiderList->sqlOrderBy = "spider.spiderID ASC"; $spiderList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php index 0972ccb9be..815178ef05 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php @@ -7,17 +7,17 @@ use wcf\system\WCF; * Caches the styles and style variables. * * @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.cache.builder * @category Community Framework */ -class StyleCacheBuilder implements ICacheBuilder { +class StyleCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'default' => 0, 'styles' => array() diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php deleted file mode 100644 index 4b4e4624ec..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class TemplateCacheBuilder implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData(array $cacheResource) { - $information = explode('-', $cacheResource['cache']); - if (count($information) == 3) { - $prefix = $information[0].'_'; - } - else { - $prefix = ''; - } - - $data = array(); - - // get all templates and filter options with low priority - $sql = "SELECT templateName, template.packageID - FROM wcf".WCF_N."_".$prefix."template"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - if (!isset($data[$row['templateName']])) { - $data[$row['templateName']] = $row['packageID']; - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php index 2f67519091..a85108ddd6 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\template\group\TemplateGroupList; * Caches template groups. * * @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.cache.builder * @category Community Framework */ -class TemplateGroupCacheBuilder implements ICacheBuilder { +class TemplateGroupCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $templateGroupList = new TemplateGroupList(); $templateGroupList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php index 624885670f..72e3133c20 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php @@ -6,22 +6,20 @@ use wcf\data\template\listener\TemplateListenerList; * Caches template listener information. * * @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.cache.builder * @category Community Framework */ -class TemplateListenerCacheBuilder implements ICacheBuilder { +class TemplateListenerCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { - list(, $environment) = explode('-', $cacheResource['cache']); - + public function rebuild(array $parameters) { // get templates for current package id $templateListenerList = new TemplateListenerList(); - $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); + $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($parameters['environment'])); $templateListenerList->readObjects(); $data = array(); 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 19328b9594..f90b7792d8 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php @@ -6,23 +6,21 @@ use wcf\data\template\listener\TemplateListenerList; * Caches the template listener code for a certain template in a certain environment. * * @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.cache.builder * @category Community Framework */ -class TemplateListenerCodeCacheBuilder implements ICacheBuilder { +class TemplateListenerCodeCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { - list($environment, $templateName) = explode('-', $cacheResource['cache']); - + public function rebuild(array $parameters) { // get template codes for specified template $templateListenerList = new TemplateListenerList(); - $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); - $templateListenerList->getConditionBuilder()->add("template_listener.templateName = ?", array($templateName)); + $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($parameters['environment'])); + $templateListenerList->getConditionBuilder()->add("template_listener.templateName = ?", array($parameters['templateName'])); $templateListenerList->readObjects(); $data = array(); diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php index 867ab476b8..35636a13f0 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php @@ -6,17 +6,17 @@ use wcf\data\user\group\UserGroupList; * Caches all user groups. * * @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.cache.builder * @category Community Framework */ -class UserGroupCacheBuilder implements ICacheBuilder { +class UserGroupCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { $data = array( 'types' => array(), 'groups' => array() diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupOptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupOptionCacheBuilder.class.php new file mode 100644 index 0000000000..e6796352ca --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupOptionCacheBuilder.class.php @@ -0,0 +1,24 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class UserGroupOptionCacheBuilder extends OptionCacheBuilder { + /** + * @see wcf\system\cache\builder\OptionCacheBuilder::$optionClassName + */ + protected $optionClassName = 'wcf\data\user\group\option\UserGroupOption'; + + /** + * @see wcf\system\cache\builder\OptionCacheBuilder::$tableName + */ + protected $tableName = 'user_group_option'; +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php index 6f03e2c1a7..d76f94217a 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -10,13 +10,13 @@ use wcf\util\StringUtil; * Caches the merged user group options for a certain user group combination. * * @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.cache.builder * @category Community Framework */ -class UserGroupPermissionCacheBuilder implements ICacheBuilder { +class UserGroupPermissionCacheBuilder extends AbstractCacheBuilder { /** * list of used group option type objects * @var array @@ -24,10 +24,9 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder { protected $typeObjects = array(); /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { - list(, $groupIDs) = explode('-', $cacheResource['cache']); + public function rebuild(array $parameters) { $data = array(); // get all options @@ -44,7 +43,7 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder { if (!empty($options)) { // get needed options $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs))); + $conditions->add("option_value.groupID IN (?)", array($parameters)); $conditions->add("option_value.optionID IN (?)", array($options)); $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue @@ -88,7 +87,7 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder { } } - $data['groupIDs'] = $groupIDs; + $data['groupIDs'] = $parameters; return $data; } diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserOptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserOptionCacheBuilder.class.php new file mode 100644 index 0000000000..dc7b251757 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/UserOptionCacheBuilder.class.php @@ -0,0 +1,24 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class UserOptionCacheBuilder extends OptionCacheBuilder { + /** + * @see wcf\system\cache\builder\OptionCacheBuilder::$optionClassName + */ + protected $optionClassName = 'wcf\data\user\option\UserOption'; + + /** + * @see wcf\system\cache\builder\OptionCacheBuilder::$tableName + */ + protected $tableName = 'user_option'; +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php index 6f47ae304a..79853226b5 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php @@ -8,17 +8,17 @@ use wcf\system\WCF; * Caches the versions for a certain package and object type. * * @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.cache.builder * @category Community Framework */ -class VersionCacheBuilder implements ICacheBuilder { +class VersionCacheBuilder extends AbstractCacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ - public function getData(array $cacheResource) { + public function rebuild(array $parameters) { // get object types $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject'); -- 2.20.1