From: Alexander Ebert Date: Mon, 25 Nov 2013 14:30:47 +0000 (+0100) Subject: Improved error handling of package update servers X-Git-Tag: 2.0.0_RC_3~8^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a1517a25228cc32717d2bf2e45af9979286c6680;p=GitHub%2FWoltLab%2FWCF.git Improved error handling of package update servers --- diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index ae1ea229ba..6a0ae154f1 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -42,16 +42,35 @@ class PackageUpdateDispatcher extends SingletonFactory { $refreshedPackageLists = false; foreach ($updateServers as $updateServer) { if ($updateServer->lastUpdateTime < TIME_NOW - 600) { + $errorMessage = ''; + try { $this->getPackageUpdateXML($updateServer); $refreshedPackageLists = true; } catch (SystemException $e) { + $errorMessage = $e->getMessage(); + } + catch (PackageUpdateUnauthorizedException $e) { + $reply = $e->getRequest()->getReply(); + foreach ($reply['headers'] as $header) { + if (preg_match('~^HTTP~', $header)) { + $errorMessage = $header; + break; + } + } + + if (!$errorMessage) { + $errorMessage = 'Unknown (HTTP status ' . (is_array($reply['statusCode']) ? reset($reply['statusCode']) : $reply['statusCode']) . ')'; + } + } + + if ($errorMessage) { // save error status $updateServerEditor = new PackageUpdateServerEditor($updateServer); $updateServerEditor->update(array( 'status' => 'offline', - 'errorMessage' => $e->getMessage() + 'errorMessage' => $errorMessage )); } }