From dd3ee2d299c7bffad7c7b7599e19664099f67c99 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 21 May 2013 12:33:59 +0200 Subject: [PATCH] Fixed update server API --- .../files/acp/templates/packageUpdateUnauthorized.tpl | 10 ++++++---- .../package/PackageInstallationScheduler.class.php | 5 ----- .../system/package/PackageUpdateDispatcher.class.php | 9 +++++---- .../PackageUpdateUnauthorizedException.class.php | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/packageUpdateUnauthorized.tpl b/wcfsetup/install/files/acp/templates/packageUpdateUnauthorized.tpl index cf6848f1c9..3b5876f4f4 100644 --- a/wcfsetup/install/files/acp/templates/packageUpdateUnauthorized.tpl +++ b/wcfsetup/install/files/acp/templates/packageUpdateUnauthorized.tpl @@ -8,10 +8,12 @@ {lang}wcf.acp.package.update.server{/lang} -
-
{lang}wcf.acp.package.name{/lang}
-
{$packageUpdateVersion[packageName]} ({$packageUpdateVersion[packageVersion]})
-
+ {if $packageUpdateVersion[packageName]|isset} +
+
{lang}wcf.acp.package.name{/lang}
+
{$packageUpdateVersion[packageName]} ({$packageUpdateVersion[packageVersion]})
+
+ {/if}
{lang}wcf.acp.package.update.server.url{/lang}
{@$updateServer->getHighlightedURL()}
diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php index 8c0dbc70e8..0a55a75481 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php @@ -235,11 +235,6 @@ class PackageInstallationScheduler { $response = $request->getReply(); // check response - // 401 = missing/invalid auth data, 403 = valid auth data, but unaccessible - if ($response['statusCode'] == 401 || $response['statusCode'] == 403) { - throw new PackageUpdateAuthorizationRequiredException($packageUpdateVersion['packageUpdateServerID'], (!empty($packageUpdateVersion['file']) ? $packageUpdateVersion['file'] : $packageUpdateVersion['server']), $response); - } - if ($response['statusCode'] != 200) { throw new SystemException(WCF::getLanguage()->get('wcf.acp.packageUpdate.error.downloadFailed', array('$package' => $package)) . ' ('.$response['body'].')'); } diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index ac522467a5..fe0ba104f7 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -8,7 +8,9 @@ use wcf\data\package\update\PackageUpdateEditor; use wcf\data\package\update\PackageUpdateList; use wcf\data\package\Package; use wcf\system\database\util\PreparedStatementConditionBuilder; +use wcf\system\exception\HTTPUnauthorizedException; use wcf\system\exception\SystemException; +use wcf\system\package\PackageUpdateUnauthorizedException; use wcf\system\Regex; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -78,13 +80,12 @@ class PackageUpdateDispatcher extends SingletonFactory { $request->execute(); $reply = $request->getReply(); } + catch (HTTPUnauthorizedException $e) { + throw new PackageUpdateUnauthorizedException($request, $updateServer); + } catch (SystemException $e) { $reply = $request->getReply(); - if ($reply['statusCode'] == 401) { - throw new PackageUpdateAuthorizationRequiredException($updateServer['packageUpdateServerID'], $updateServer['server'], $reply); - } - throw new SystemException(WCF::getLanguage()->get('wcf.acp.packageUpdate.error.listNotFound') . ' ('.reset($reply['headers']).')'); } diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php index d6fbbeddb1..9d970edde7 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php @@ -42,7 +42,7 @@ class PackageUpdateUnauthorizedException extends UserException { * @param wcf\data\package\update\server\PackageUpdateServer $updateServer * @param array $packageUpdateVersion */ - public function __construct(HTTPRequest $request, PackageUpdateServer $updateServer, array $packageUpdateVersion) { + public function __construct(HTTPRequest $request, PackageUpdateServer $updateServer, array $packageUpdateVersion = array()) { $this->request = $request; $this->updateServer = $updateServer; $this->packageUpdateVersion = $packageUpdateVersion; -- 2.20.1