Index: trunk/core/kernel/utility/temp_handler.php =================================================================== diff -u -r5174 -r5176 --- trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5174) +++ trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5176) @@ -453,15 +453,9 @@ // because items from Sub Tables get deteleted in CopySubTablesToLive !BY ForeignKey! if ($master['TableName'] == $this->MasterTable) { $this->RaiseEvent( 'OnBeforeDeleteFromLive', $master['Prefix'], '', $current_ids ); - - // Do not delete live items with 0 id - // otherwise home category permissions got deleted when creating new category - $del_ids = $current_ids; - array_splice($del_ids, array_search(0, $current_ids), 1); - if (count($del_ids) >= 1) { - $query = 'DELETE FROM '.$master['TableName'].' WHERE '.$master['IdField'].' IN ('.join(',', $del_ids).')'; - $this->Conn->Query($query); - } + + $query = 'DELETE FROM '.$master['TableName'].' WHERE '.$master['IdField'].' IN ('.join(',', $current_ids).')'; + $this->Conn->Query($query); } if ( getArrayValue($master, 'SubTables') ) { @@ -578,9 +572,15 @@ // delete records from live table by foreign key, so that records deleted from temp table // get deleted from live if (count($current_ids) > 0 && !in_array($table_sig, $this->CopiedTables) ) { - $foreign_key_field = is_array($sub_table['ForeignKey']) ? getArrayValue($sub_table, 'ForeignKey', $master['Prefix']) : $sub_table['ForeignKey']; + $foreign_key_field = is_array($sub_table['ForeignKey']) ? getArrayValue($sub_table, 'ForeignKey', $master['Prefix']) : $sub_table['ForeignKey']; if (!$foreign_key_field) continue; $foreign_keys = $this->GetForeignKeys($master, $sub_table, $current_ids); + // Do not delete live sub-items with 0 id + // otherwise home category permissions got deleted when creating new category + $zero_id = array_search(0, $foreign_keys); + if ($zero_id !== false) { + array_splice($foreign_keys, $zero_id, 1); + } if (count($foreign_keys) > 0) { $query = 'SELECT '.$sub_table['IdField'].' FROM '.$sub_table['TableName'].' WHERE '.$foreign_key_field.' IN ('.join(',', $foreign_keys).')';