[BUGFIX] Ensure correct return type for AbstractFile getters 95/48195/4
authorMarkus Klein <markus.klein@typo3.org>
Tue, 17 May 2016 12:23:24 +0000 (14:23 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Mon, 30 May 2016 11:40:40 +0000 (13:40 +0200)
Resolves: #76212
Releases: master, 7.6
Change-Id: I7b7ded93ff1d31f00f8d067f9697cd8f71305881
Reviewed-on: https://review.typo3.org/48195
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Resource/AbstractFile.php

index 7736871..5801a89 100644 (file)
@@ -183,14 +183,19 @@ abstract class AbstractFile implements FileInterface
      * Returns the size of this file
      *
      * @throws \RuntimeException
-     * @return int
+     * @return int|null Returns null if size is not available for the file
      */
     public function getSize()
     {
         if ($this->deleted) {
             throw new \RuntimeException('File has been deleted.', 1329821480);
         }
-        return $this->properties['size'] ?: array_pop($this->getStorage()->getFileInfoByIdentifier($this->getIdentifier(), array('size')));
+        if (empty($this->properties['size'])) {
+            $size = array_pop($this->getStorage()->getFileInfoByIdentifier($this->getIdentifier(), array('size')));
+        } else {
+            $size = $this->properties['size'];
+        }
+        return $size ? (int)$size : null;
     }
 
     /**
@@ -200,7 +205,7 @@ abstract class AbstractFile implements FileInterface
      */
     public function getUid()
     {
-        return $this->getProperty('uid');
+        return (int)$this->getProperty('uid');
     }
 
     /**
@@ -228,7 +233,7 @@ abstract class AbstractFile implements FileInterface
         if ($this->deleted) {
             throw new \RuntimeException('File has been deleted.', 1329821487);
         }
-        return $this->getProperty('creation_date');
+        return (int)$this->getProperty('creation_date');
     }
 
     /**
@@ -242,7 +247,7 @@ abstract class AbstractFile implements FileInterface
         if ($this->deleted) {
             throw new \RuntimeException('File has been deleted.', 1329821488);
         }
-        return $this->getProperty('modification_date');
+        return (int)$this->getProperty('modification_date');
     }
 
     /**