From 6df8b549a4ceb8e2ff6cd3b801aefa371a0fbd71 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 25 Jul 2011 17:16:40 +0200 Subject: [PATCH] Delete ICleanupHandler file --- .../system/cleanup/ICleanupHandler.class.php | 172 ------------------ 1 file changed, 172 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/cleanup/ICleanupHandler.class.php diff --git a/wcfsetup/install/files/lib/system/cleanup/ICleanupHandler.class.php b/wcfsetup/install/files/lib/system/cleanup/ICleanupHandler.class.php deleted file mode 100644 index 6a1af42c69..0000000000 --- a/wcfsetup/install/files/lib/system/cleanup/ICleanupHandler.class.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cleanup - * @category Community Framework - */ -class ICleanupHandler { - /** - * unique instance of CleanupHandler - * - * @var 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-'.PACKAGE_ID, - WCF_DIR.'cache/cache.cleanupAdapter.php', - 'wcf\system\cache\builder\CacheBuilderCleanupAdapter' - ); - - $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 (count($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']."'", 11001); - } - - // validate interface - if (!(ClassUtil::isInstanceOf($adapterData['className'], 'wcf\system\cleanup\ICleanupAdapter'))) { - throw new SystemException("class '".$adapterData['className']."' does not implement the interface 'wcf\system\cleanup\ICleanupAdapter'", 11010); - } - - $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 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 - )); - } - } -} -- 2.20.1