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>
Mon, 19 Mar 2018 16:15:14 +0000 (17:15 +0100)
Backport of 088a81d4c5f3208e85a0da594b932e4706ccbaf5
See #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 a94d0c287f334827305da8b8941e621e45ebd64a..916e36685348d16074d2713e93ba0f57f239b1c3 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;
@@ -10,7 +11,7 @@ use wcf\util\FileUtil;
  * 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
  *
@@ -228,4 +229,31 @@ class PackageUpdateServer extends DatabaseObject {
                
                return false;
        }
+       
+       /**
+        * 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
+               ]);
+       }
 }