Reset update servers when clearing global cache
authorAlexander Ebert <ebert@woltlab.com>
Wed, 14 Feb 2018 12:56:30 +0000 (13:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Feb 2018 12:56:30 +0000 (13:56 +0100)
Closes #2538

wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php
wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php

index d734d51f1a18dc7c448d898c5c0de89bd44e4489..2061443d86a53ab9e62c5b357bbd384f3867bc91 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\acp\action;
 use wcf\action\AbstractAction;
+use wcf\data\package\update\server\PackageUpdateServer;
 use wcf\system\cache\CacheHandler;
 use wcf\system\language\LanguageFactory;
 use wcf\system\request\LinkHandler;
@@ -11,7 +12,7 @@ use wcf\util\HeaderUtil;
  * Clears the cache.
  * 
  * @author     Tim Duesterhus
- * @copyright  2001-2017 WoltLab GmbH
+ * @copyright  2001-2018 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\Acp\Action
  */
@@ -36,6 +37,9 @@ class CacheClearAction extends AbstractAction {
                // get package dirs
                CacheHandler::getInstance()->flushAll();
                
+               // reset package update servers and the package cache
+               PackageUpdateServer::resetAll();
+               
                $this->executed();
                
                if (!isset($_POST['noRedirect'])) {
index 03fa2c072eb63ad145f51aa6c2afee06edcbd491..4187bfe410f2f71726f3dc65a9e6991ab27ae98a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\package\update\server;
 use wcf\data\DatabaseObject;
+use wcf\system\cache\builder\PackageUpdateCacheBuilder;
 use wcf\system\io\RemoteFile;
 use wcf\system\Regex;
 use wcf\system\WCF;
@@ -11,7 +12,7 @@ use wcf\util\Url;
  * Represents a package update server.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2017 WoltLab GmbH
+ * @copyright  2001-2018 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\Data\Package\Update\Server
  *
@@ -238,4 +239,31 @@ class PackageUpdateServer extends DatabaseObject {
        public function isWoltLabStoreServer() {
                return Url::parse($this->serverURL)['host'] === 'store.woltlab.com';
        }
+       
+       /**
+        * Resets all update servers into their original state and purges
+        * the package cache.
+        */
+       public static function resetAll() {
+               // purge package cache
+               WCF::getDB()->prepareStatement("DELETE FROM wcf".WCF_N."_package_update")->execute();
+               
+               PackageUpdateCacheBuilder::getInstance()->reset();
+               
+               // reset servers into their original state
+               $sql = "UPDATE  wcf".WCF_N."_package_update_server
+                       SET     lastUpdateTime = ?,
+                               status = ?,
+                               errorMessage = ?,
+                               apiVersion = ?,
+                               metaData = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute([
+                       0,
+                       'online',
+                       '',
+                       '2.0',
+                       null
+               ]);
+       }
 }