[BUGFIX] Storage is offline but is still used 32/23232/2
authorFrans Saris <franssaris@gmail.com>
Wed, 7 Aug 2013 10:09:54 +0000 (12:09 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 3 Sep 2013 13:05:16 +0000 (15:05 +0200)
Check before generating a publicUrl if storage is online.

Resolves: #49842
Releases: 6.2, 6.1, 6.0
Change-Id: I766e337cf5e7dfcb309bbce0bbd7c4d8df733c84
Reviewed-on: https://review.typo3.org/23232
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php

index 975280d..d5311d5 100644 (file)
@@ -764,11 +764,13 @@ class ResourceStorage {
         */
        public function getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript = FALSE) {
                $publicUrl = NULL;
-               // Pre-process the public URL by an accordant slot
-               $this->emitPreGeneratePublicUrl($resourceObject, $relativeToCurrentScript, array('publicUrl' => &$publicUrl));
-               // If slot did not handle the signal, use the default way to determine public URL
-               if ($publicUrl === NULL) {
-                       $publicUrl = $this->driver->getPublicUrl($resourceObject, $relativeToCurrentScript);
+               if ($this->isOnline()) {
+                       // Pre-process the public URL by an accordant slot
+                       $this->emitPreGeneratePublicUrl($resourceObject, $relativeToCurrentScript, array('publicUrl' => &$publicUrl));
+                       // If slot did not handle the signal, use the default way to determine public URL
+                       if ($publicUrl === NULL) {
+                               $publicUrl = $this->driver->getPublicUrl($resourceObject, $relativeToCurrentScript);
+                       }
                }
                return $publicUrl;
        }
index 90e2516..fd4a80d 100644 (file)
@@ -271,6 +271,22 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
        }
 
        /**
+        * @test
+        */
+       public function getPublicUrlReturnsNullIfStorageIsNotOnline() {
+               /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
+               $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array(), array(array('basePath' => $this->getMountRootUrl())));
+               /** @var $fixture \TYPO3\CMS\Core\Resource\ResourceStorage */
+               $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('isOnline'), array($driver, array('configuration' => array())));
+               $fixture->expects($this->once())->method('isOnline')->will($this->returnValue(FALSE));
+
+               $sourceFileIdentifier = '/sourceFile.ext';
+               $sourceFile = $this->getSimpleFileMock($sourceFileIdentifier);
+               $result = $fixture->getPublicUrl($sourceFile);
+               $this->assertSame($result, NULL);
+       }
+
+       /**
         * Data provider for checkFolderPermissionsRespectsFilesystemPermissions
         *
         * @return array