Force-skip the etag check for woltlab servers w/ auth code
authorAlexander Ebert <ebert@woltlab.com>
Sun, 1 Apr 2018 18:24:09 +0000 (20:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 1 Apr 2018 18:24:16 +0000 (20:24 +0200)
wcfsetup/install/files/lib/system/cronjob/GetUpdateInfoCronjob.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php

index 83359f397a3799573368fb4d90aa44f53da6a6a1..3877a7e425f673464d23796ffd0ddd1faef009f7 100644 (file)
@@ -18,6 +18,6 @@ class GetUpdateInfoCronjob extends AbstractCronjob {
        public function execute(Cronjob $cronjob) {
                parent::execute($cronjob);
                
-               PackageUpdateDispatcher::getInstance()->refreshPackageDatabase();
+               PackageUpdateDispatcher::getInstance()->refreshPackageDatabase([], true);
        }
 }
index 56d7302cde9f8e5444f0f88bd904fe76949a098a..b6e385eeb3bbbf26a074f48507a1eeb2daf3bf46 100644 (file)
@@ -47,7 +47,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                $requirePurchasedVersions = false;
                foreach ($tmp as $updateServer) {
                        if ($ignoreCache || $updateServer->lastUpdateTime < TIME_NOW - 600) {
-                               if (preg_match('~^https?://(?:update|store)\.woltlab\.com~', $updateServer->serverURL)) {
+                               if (preg_match('~^https?://(?:update|store)\.woltlab\.com\/~', $updateServer->serverURL)) {
                                        $requirePurchasedVersions = true;
                                        
                                        // move a woltlab.com update server to the front of the queue to probe for SSL support
@@ -145,9 +145,12 @@ class PackageUpdateDispatcher extends SingletonFactory {
                $request = new HTTPRequest($updateServer->getListURL($forceHTTP), $settings);
                
                if ($updateServer->apiVersion == '2.1') {
-                       $metaData = $updateServer->getMetaData();
-                       if (isset($metaData['list']['etag'])) $request->addHeader('if-none-match', $metaData['list']['etag']);
-                       if (isset($metaData['list']['lastModified'])) $request->addHeader('if-modified-since', $metaData['list']['lastModified']);
+                       // skip etag check for WoltLab servers when an auth code is provided
+                       if (!preg_match('~^https?://(?:update|store)\.woltlab\.com\/~', $updateServer->serverURL) || !PACKAGE_SERVER_AUTH_CODE) {
+                               $metaData = $updateServer->getMetaData();
+                               if (isset($metaData['list']['etag'])) $request->addHeader('if-none-match', $metaData['list']['etag']);
+                               if (isset($metaData['list']['lastModified'])) $request->addHeader('if-modified-since', $metaData['list']['lastModified']);
+                       }
                }
                
                try {
@@ -163,7 +166,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                        $statusCode = is_array($reply['statusCode']) ? reset($reply['statusCode']) : $reply['statusCode'];
                        // status code 0 is a connection timeout
                        if (!$statusCode && $secureConnection) {
-                               if (preg_match('~https?://(?:update|store)\.woltlab\.com~', $updateServer->serverURL)) {
+                               if (preg_match('~https?://(?:update|store)\.woltlab\.com\/~', $updateServer->serverURL)) {
                                        // woltlab.com servers are most likely to be available, thus we assume that SSL connections are dropped
                                        RemoteFile::disableSSL();
                                }