From dc24d3f21f4a9a62c1571a3235007bb2292816f3 Mon Sep 17 00:00:00 2001 From: cwchong Date: Tue, 19 May 2015 13:43:00 +0800 Subject: [PATCH] Bug fix: File->setName() Logical error. $base should use PATHINFO_FILENAME instead of PATHINFO_BASENAME in order to exclude extension; final $name should include a period before $ext as $ext uses PATHINFO_EXTENSION which excludes the period. --- filesystem/File.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filesystem/File.php b/filesystem/File.php index a6a4f9f29..47fc95af8 100644 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -609,7 +609,7 @@ class File extends DataObject { // If it's changed, check for duplicates if($oldName && $oldName != $name) { - $base = pathinfo($name, PATHINFO_BASENAME); + $base = pathinfo($name, PATHINFO_FILENAME); $ext = self::get_file_extension($name); $suffix = 1; @@ -621,7 +621,7 @@ class File extends DataObject { ))->first() ) { $suffix++; - $name = "$base-$suffix$ext"; + $name = "$base-$suffix.$ext"; } }