From 088a81d4c5f3208e85a0da594b932e4706ccbaf5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 14 Feb 2018 13:56:30 +0100 Subject: [PATCH] Reset update servers when clearing global cache Closes #2538 --- .../lib/acp/action/CacheClearAction.class.php | 6 +++- .../server/PackageUpdateServer.class.php | 30 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php index d734d51f1a..2061443d86 100644 --- a/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/CacheClearAction.class.php @@ -1,6 +1,7 @@ * @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'])) { diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index 03fa2c072e..4187bfe410 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -1,6 +1,7 @@ * @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 + ]); + } } -- 2.20.1