Index: branches/5.3.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r15938 -r15986 --- branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15938) +++ branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15986) @@ -1,6 +1,6 @@ Conn->Query($sql); } else { - $fields_hash = Array( + $fields_hash = Array ( 'CategoryId' => $category_id, 'ItemResourceId' => $this->GetField('ResourceId'), 'PrimaryCat' => $is_primary ? 1 : 0, 'ItemPrefix' => $this->Prefix, 'Filename' => $this->useFilenames ? (string)$this->GetDBField('Filename') : '', // because some prefixes does not use filenames, ); + if ( $this->Application->IsTempTable($table) ) { + $new_id = (int)$this->Conn->GetOne('SELECT MIN(Id) FROM ' . $table .' WHERE Id < 0' ); + $fields_hash['Id'] = $new_id - 1; + } + $this->Conn->doInsert($fields_hash, $table); }