Index: trunk/kernel/include/item.php =================================================================== diff -u -r3260 -r3261 --- trunk/kernel/include/item.php (.../item.php) (revision 3260) +++ trunk/kernel/include/item.php (.../item.php) (revision 3261) @@ -1128,11 +1128,13 @@ $db =& GetADODBConnection(); $sql = 'SELECT '.$this->IdField().' FROM '.$this->tablename.' WHERE Filename = '.$db->qstr($filename); - $found_item_id = $db->GetOne($sql); + $found_item_ids = $db->GetCol($sql); $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets); - if( ($found_item_id != $this->UniqueId()) || $has_page ) // other category has same filename as ours OR we have filename, that ends with _number + + $duplicates_found = (count($found_item_ids) > 1); + if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number { - $append = $found_item_id ? 'a' : ''; + $append = $duplicates_found ? 'a' : ''; if($has_page) { $filename = $rets[1].'_'.$rets[2]; Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -r3253 -r3261 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3253) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3261) @@ -217,20 +217,21 @@ if(!$filename || is_null( $this->GetID() ) ) return $filename; // check temp table - $sql = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename); - $found_item_id = $this->Conn->GetOne($sql); + $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename); + $found_temp_ids = $this->Conn->GetCol($sql_temp); - if($found_item_id === false) - { - // check live table - $sql = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename); - $found_item_id = $this->Conn->GetOne($sql); - } + // check live table + $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename); + $found_live_ids = $this->Conn->GetCol($sql_live); + $found_item_ids = array_unique( array_merge($found_temp_ids, $found_live_ids) ); + $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets); - if( ($found_item_id != $this->GetID()) || $has_page ) // other category has same filename as ours OR we have filename, that ends with _number + + $duplicates_found = (count($found_item_ids) > 1); + if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number { - $append = $found_item_id ? 'a' : ''; + $append = $duplicates_found ? 'a' : ''; if($has_page) { $filename = $rets[1].'_'.$rets[2]; Index: trunk/kernel/units/general/cat_dbitem.php =================================================================== diff -u -r3253 -r3261 --- trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3253) +++ trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3261) @@ -217,20 +217,21 @@ if(!$filename || is_null( $this->GetID() ) ) return $filename; // check temp table - $sql = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename); - $found_item_id = $this->Conn->GetOne($sql); + $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename); + $found_temp_ids = $this->Conn->GetCol($sql_temp); - if($found_item_id === false) - { - // check live table - $sql = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename); - $found_item_id = $this->Conn->GetOne($sql); - } + // check live table + $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename); + $found_live_ids = $this->Conn->GetCol($sql_live); + $found_item_ids = array_unique( array_merge($found_temp_ids, $found_live_ids) ); + $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets); - if( ($found_item_id != $this->GetID()) || $has_page ) // other category has same filename as ours OR we have filename, that ends with _number + + $duplicates_found = (count($found_item_ids) > 1); + if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number { - $append = $found_item_id ? 'a' : ''; + $append = $duplicates_found ? 'a' : ''; if($has_page) { $filename = $rets[1].'_'.$rets[2];