mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +02:00
FIX: Ignore current instance when checking for duplicate records (Fixes #1927)
This commit is contained in:
parent
a50996a010
commit
0b22ca6c59
@ -596,9 +596,14 @@ class File extends DataObject {
|
||||
$base = pathinfo($name, PATHINFO_BASENAME);
|
||||
$ext = self::get_file_extension($name);
|
||||
$suffix = 1;
|
||||
while(DataObject::get_one("File", "\"Name\" = '" . Convert::raw2sql($name)
|
||||
. "' AND \"ParentID\" = " . (int)$this->ParentID)) {
|
||||
|
||||
while(File::get()->filter(array(
|
||||
'Name' => $name,
|
||||
'ParentID' => (int) $this->ParentID
|
||||
))->exclude(array(
|
||||
'ID' => $this->ID
|
||||
))->first()
|
||||
) {
|
||||
$suffix++;
|
||||
$name = "$base-$suffix$ext";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user