From: Alexander Ebert Date: Wed, 14 Feb 2018 12:56:30 +0000 (+0100) Subject: Reset update servers when clearing global cache X-Git-Tag: 3.1.2~2^2~41 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f6436eceff7f477bbabea50c2d2a636abc44c72b;p=GitHub%2FWoltLab%2FWCF.git Reset update servers when clearing global cache Backport of 088a81d4c5f3208e85a0da594b932e4706ccbaf5 See #2538 --- 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 + ]); + } }