From 1117583bd5f9c1208539f684e2d5feb9a76083c4 Mon Sep 17 00:00:00 2001 From: Markus Klein <markus.klein@typo3.org> Date: Tue, 17 May 2016 14:23:24 +0200 Subject: [PATCH] [BUGFIX] Ensure correct return type for AbstractFile getters 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> --- .../sysext/core/Classes/Resource/AbstractFile.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/core/Classes/Resource/AbstractFile.php b/typo3/sysext/core/Classes/Resource/AbstractFile.php index 77368715a3c6..5801a894a749 100644 --- a/typo3/sysext/core/Classes/Resource/AbstractFile.php +++ b/typo3/sysext/core/Classes/Resource/AbstractFile.php @@ -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'); } /** -- GitLab