]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #5207 returning false if filename is not set
authorCash Costello <cash.costello@gmail.com>
Sun, 21 Apr 2013 16:20:21 +0000 (12:20 -0400)
committerCash Costello <cash.costello@gmail.com>
Sun, 21 Apr 2013 16:20:21 +0000 (12:20 -0400)
engine/classes/ElggDiskFilestore.php

index 663d33c02a784e08e305560a9390d96fc7619c6e..6e23540121bd6f7092d6e88b7d3d9894a4e0dc67 100644 (file)
@@ -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));
        }