FIX: Ignore current instance when checking for duplicate records (Fixes #1927)

This commit is contained in:
Will Rossiter 2014-01-12 20:54:55 +13:00
parent a50996a010
commit 0b22ca6c59

View File

@ -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";
}