]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14589: strrpos is needed to check the last occurence
authorscyrma <scyrma>
Fri, 5 Sep 2008 09:23:36 +0000 (09:23 +0000)
committerscyrma <scyrma>
Fri, 5 Sep 2008 09:23:36 +0000 (09:23 +0000)
MDL-15405: return the existing file in case one is found

lib/file/file_storage.php

index 03663e11d9e4fae8b9f2cdc244d106aa41c1f1f3..dfa01a6419f2895d6df69e5c0cbfee383beda335 100644 (file)
@@ -394,7 +394,7 @@ class file_storage {
 
             if ($key == 'filepath') {
                 $value = clean_param($value, PARAM_PATH);
-                if (strpos($value, '/') !== 0 or strpos($value, '/') !== strlen($value)-1) {
+                if (strpos($value, '/') !== 0 or strrpos($value, '/') !== strlen($value)-1) {
                     // path must start and end with '/'
                     throw new file_exception('storedfileproblem', 'Invalid file path');
                 }
@@ -621,6 +621,7 @@ class file_storage {
                 if ($overwrite) {
                     $oldfile->delete();
                 } else {
+                    $returnfiles[] = $oldfile;
                     continue;   // Can't overwrite the existing file so skip it
                 }
             }