Просмотр исходного кода

#3384 Automatic redirect from local storage to remote storage if some references still point to local storage

Alex Trofimov 5 лет назад
Родитель
Сommit
64ec314b26
1 измененных файлов с 11 добавлено и 10 удалено
  1. 11 10
      storage.php

+ 11 - 10
storage.php

@@ -32,21 +32,22 @@ if (!$sRemoteId) {
 // redirect for remote storage in case if some references still pointing to local storage
 $aObject = $oStorage->getObjectData();
 if ('Local' != $aObject['engine']) {
-    if (!($sUrl = $oStorage->getFileUrlByRemoteId($sFile))) {
+    $sUrl = $oStorage->getFileUrlByRemoteId($sFile);
 
+    if (!$sUrl) {
         $sFile = preg_replace("/\.[A-Za-z0-9]+$/", '', $sFile);
         $sUrl = $oStorage->getFileUrlByRemoteId($sFile);
+    }
 
-        // Tmp fix for storages renaming in the past
-        if (!$sUrl && 'bx_posts_files' == $sStorageObject && ($oStorage = BxDolStorage::getObjectInstance('bx_posts_covers'))) 
-            $sUrl = $oStorage->getFileUrlByRemoteId($sFile);
+    // Tmp fix for storages renaming in the past
+    if (!$sUrl && 'bx_posts_files' == $sStorageObject && ($oStorage = BxDolStorage::getObjectInstance('bx_posts_covers'))) 
+        $sUrl = $oStorage->getFileUrlByRemoteId($sFile);
 
-        if (!$sUrl) {
-            bx_storage_download_error_occured();
-            exit;
-        }
-    }
-    header("Location: " . $sUrl);
+    if (!$sUrl)
+        bx_storage_download_error_occured();
+    else
+        header("Location: " . $sUrl);
+    exit;
 }
 
 if (!$oStorage->download($sRemoteId, $sToken)) {