mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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.
This commit is contained in:
parent
0ba3ada15b
commit
dc24d3f21f
@ -609,7 +609,7 @@ class File extends DataObject {
|
|||||||
|
|
||||||
// If it's changed, check for duplicates
|
// If it's changed, check for duplicates
|
||||||
if($oldName && $oldName != $name) {
|
if($oldName && $oldName != $name) {
|
||||||
$base = pathinfo($name, PATHINFO_BASENAME);
|
$base = pathinfo($name, PATHINFO_FILENAME);
|
||||||
$ext = self::get_file_extension($name);
|
$ext = self::get_file_extension($name);
|
||||||
$suffix = 1;
|
$suffix = 1;
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ class File extends DataObject {
|
|||||||
))->first()
|
))->first()
|
||||||
) {
|
) {
|
||||||
$suffix++;
|
$suffix++;
|
||||||
$name = "$base-$suffix$ext";
|
$name = "$base-$suffix.$ext";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user