[BUGFIX] Use correct storage when getting public url of processed file 64/43364/5
authorNicole Cordes <typo3@cordes.co>
Tue, 15 Sep 2015 23:42:09 +0000 (01:42 +0200)
committerFrans Saris <franssaris@gmail.com>
Fri, 25 Sep 2015 17:59:08 +0000 (19:59 +0200)
If the processed file object is marked configured to use the original
file we have to ensure the right storage is used when creating the
publicUrl.

Resolves: #69833
Releases: master, 6.2
Change-Id: Iba0b4c7b8ef8b65cceae86ada0a7c7e85f338fdf
Reviewed-on: http://review.typo3.org/43364
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Resource/AbstractFile.php
typo3/sysext/core/Classes/Resource/ProcessedFile.php

index 6332c94..aeb6340 100644 (file)
@@ -490,9 +490,8 @@ abstract class AbstractFile implements FileInterface {
         * WARNING: Access to the file may be restricted by further means, e.g. some
         * web-based authentication. You have to take care of this yourself.
         *
-        * @param bool  $relativeToCurrentScript   Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
-        *
-        * @return null|string
+        * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
+        * @return NULL|string NULL if file is deleted, the generated URL otherwise
         */
        public function getPublicUrl($relativeToCurrentScript = FALSE) {
                if ($this->deleted) {
index bd8bb6c..55437d1 100644 (file)
@@ -520,4 +520,19 @@ class ProcessedFile extends AbstractFile {
                return $name;
        }
 
+       /**
+        * Returns a publicly accessible URL for this file
+        *
+        * @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all
+        * @return NULL|string NULL if file is deleted, the generated URL otherwise
+        */
+       public function getPublicUrl($relativeToCurrentScript = FALSE) {
+               if ($this->deleted) {
+                       return NULL;
+               } elseif ($this->usesOriginalFile()) {
+                       return $this->getOriginalFile()->getPublicUrl($relativeToCurrentScript);
+               } else {
+                       return $this->getStorage()->getPublicUrl($this, $relativeToCurrentScript);
+               }
+       }
 }