diff options
author | Cash Costello <cash.costello@gmail.com> | 2013-04-21 12:20:21 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2013-04-21 12:20:21 -0400 |
commit | 6f3df999223874592b6cf4f8399b5f9a3fa5bbd1 (patch) | |
tree | 7dab2d20070e28c9ef8f3b2b8d470846f7167f28 | |
parent | ed99f7b064a0749603f16644ba735de7ba93c17e (diff) | |
download | elgg-6f3df999223874592b6cf4f8399b5f9a3fa5bbd1.tar.gz elgg-6f3df999223874592b6cf4f8399b5f9a3fa5bbd1.tar.bz2 |
Fixes #5207 returning false if filename is not set
-rw-r--r-- | engine/classes/ElggDiskFilestore.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/engine/classes/ElggDiskFilestore.php b/engine/classes/ElggDiskFilestore.php index 663d33c02..6e2354012 100644 --- a/engine/classes/ElggDiskFilestore.php +++ b/engine/classes/ElggDiskFilestore.php @@ -194,7 +194,9 @@ class ElggDiskFilestore extends ElggFilestore { } /** - * Returns the filename as saved on disk for an ElggFile object + * Get the filename as saved on disk for an ElggFile object + * + * Returns an empty string if no filename set * * @param ElggFile $file File object * @@ -213,7 +215,12 @@ class ElggDiskFilestore extends ElggFilestore { throw new InvalidParameterException($msg); } - return $this->dir_root . $this->makeFileMatrix($owner_guid) . $file->getFilename(); + $filename = $file->getFilename(); + if (!$filename) { + return ''; + } + + return $this->dir_root . $this->makeFileMatrix($owner_guid) . $filename; } /** @@ -221,7 +228,7 @@ class ElggDiskFilestore extends ElggFilestore { * * @param ElggFile $file File object * - * @return mixed + * @return string */ public function grabFile(ElggFile $file) { return file_get_contents($file->getFilenameOnFilestore()); @@ -235,6 +242,9 @@ class ElggDiskFilestore extends ElggFilestore { * @return bool */ public function exists(ElggFile $file) { + if (!$file->getFilename()) { + return false; + } return file_exists($this->getFilenameOnFilestore($file)); } |