From: Marcel Werk Date: Thu, 25 Apr 2013 23:33:02 +0000 (+0200) Subject: Fixed last modification time of templates X-Git-Tag: 2.0.0_Beta_1~295^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=577229e310c41fa2a4d3cd51132e1ed67a13ccd2;p=GitHub%2FWoltLab%2FWCF.git Fixed last modification time of templates --- diff --git a/wcfsetup/install/files/lib/system/package/TemplatesFileHandler.class.php b/wcfsetup/install/files/lib/system/package/TemplatesFileHandler.class.php index 431071c479..3697cb651d 100644 --- a/wcfsetup/install/files/lib/system/package/TemplatesFileHandler.class.php +++ b/wcfsetup/install/files/lib/system/package/TemplatesFileHandler.class.php @@ -1,11 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.package @@ -16,4 +18,59 @@ class TemplatesFileHandler extends ACPTemplatesFileHandler { * @see wcf\system\package\ACPTemplatesFileHandler::$tableName */ protected $tableName = 'template'; + + /** + * @see wcf\system\setup\IFileHandler::logFiles() + */ + public function logFiles(array $files) { + $packageID = $this->packageInstallation->getPackageID(); + + // remove file extension + foreach ($files as &$file) { + $file = preg_replace('~.tpl$~', '', $file); + } + unset($file); + + // get existing templates + $existingTemplates = $updateTemplateIDs = array(); + $sql = "SELECT templateName, templateID + FROM wcf".WCF_N."_template + WHERE packageID = ? + AND templateGroupID IS NULL"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + $existingTemplates[$row['templateName']] = $row['templateID']; + } + + // save new templates + $sql = "INSERT INTO wcf".WCF_N."_template + (packageID, templateName, lastModificationTime) + VALUES (?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + foreach ($files as $file) { + if (isset($existingTemplates[$file])) { + $updateTemplateIDs[] = $existingTemplates[$file]; + continue; + } + + $statement->execute(array( + $packageID, + $file, + TIME_NOW + )); + } + + if (!empty($updateTemplateIDs)) { + // update old templates + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add('templateID IN (?)', array($updateTemplateIDs)); + + $sql = "UPDATE wcf".WCF_N."_template + SET lastModificationTime = ? + ".$conditionBuilder; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array_merge(array(TIME_NOW), $conditionBuilder->getParameters())); + } + } }