From f6436eceff7f477bbabea50c2d2a636abc44c72b 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 Backport of 088a81d4c5f3208e85a0da594b932e4706ccbaf5 See #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 a94d0c287f..916e366853 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 * @@ -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 + ]); + } } -- 2.20.1