Fixed update server API
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 May 2013 10:33:59 +0000 (12:33 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 May 2013 10:33:59 +0000 (12:33 +0200)
wcfsetup/install/files/acp/templates/packageUpdateUnauthorized.tpl
wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php

index cf6848f1c92a9cf089048c8079923cf0c37ab432..3b5876f4f4fa3d4fad3ec38530e9c9710d271d05 100644 (file)
@@ -8,10 +8,12 @@
 <fieldset{if !$serverAuthData|empty} class="marginTop"{/if}>
        <legend>{lang}wcf.acp.package.update.server{/lang}</legend>
        
-       <dl>
-               <dt>{lang}wcf.acp.package.name{/lang}</dt>
-               <dd>{$packageUpdateVersion[packageName]} ({$packageUpdateVersion[packageVersion]})</dd>
-       </dl>
+       {if $packageUpdateVersion[packageName]|isset}
+               <dl>
+                       <dt>{lang}wcf.acp.package.name{/lang}</dt>
+                       <dd>{$packageUpdateVersion[packageName]} ({$packageUpdateVersion[packageVersion]})</dd>
+               </dl>
+       {/if}
        <dl>
                <dt>{lang}wcf.acp.package.update.server.url{/lang}</dt>
                <dd>{@$updateServer->getHighlightedURL()}</dd>
index 8c0dbc70e821cb633e5289d7b50a40242f96f996..0a55a75481981aa8ce306813dfb9e0e89c374da9 100644 (file)
@@ -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'].')');
                        }
index ac522467a54383500bd089a6658c30521fa0f638..fe0ba104f790285a19e5eb021b7325eaa93dc13d 100644 (file)
@@ -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']).')');
                }
                
index d6fbbeddb14bc49c69592b7448199aa3f263758c..9d970edde7a8324600292de4c7de53fa5a1d4f1b 100644 (file)
@@ -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;