Index: trunk/core/kernel/utility/temp_handler.php =================================================================== diff -u -N -r2800 -r3073 --- trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 2800) +++ trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 3073) @@ -142,11 +142,16 @@ 'AutoDelete' => $this->Application->getUnitOption($prefix,'AutoDelete'), 'TableId' => $this->TableIdCounter++, ); - $this->FinalRefs[$tmp['TableName']] = $tmp['TableId']; + $this->FinalRefs[ $tmp['TableName'] ] = $tmp['TableId']; + $constrain = $this->Application->getUnitOption($prefix,'Constrain'); - if ($constrain) $tmp['Constrain'] = $constrain; - + if ($constrain) + { + $tmp['Constrain'] = $constrain; + $this->FinalRefs[ $tmp['TableName'].$tmp['Constrain'] ] = $tmp['TableId']; + } + $SubItems = $this->Application->getUnitOption($prefix,'SubItems'); $same_sub_counter = 1; if( is_array($SubItems) ) @@ -433,7 +438,7 @@ } if ( getArrayValue($master, 'SubTables') ) { - if( in_array($table_sig, $this->CopiedTables) ) continue; + if( in_array($table_sig, $this->CopiedTables) || $this->FinalRefs[$table_sig] != $master['TableId'] ) return; foreach($current_ids AS $id) { @@ -477,7 +482,7 @@ // when all of ids in current master has been processed, copy all sub-tables data $this->CopySubTablesToLive($master, $current_ids); } - elseif( !in_array($table_sig, $this->CopiedTables) ) { //If current master doesn't have sub-tables - we could use mass operations + elseif( !in_array($table_sig, $this->CopiedTables) && ($this->FinalRefs[$table_sig] == $master['TableId']) ) { //If current master doesn't have sub-tables - we could use mass operations // We don't need to delete items from live here, as it get deleted in the beggining of the method for MasterTable // or in parent table processing for sub-tables $this->RaiseEvent('OnBeforeCopyToLive', $master['Prefix'], $current_ids); @@ -510,7 +515,7 @@ } } - if ($this->FinalRefs[$master['TableName']] != $master['TableId']) return; + if ($this->FinalRefs[ $master['TableName'] ] != $master['TableId']) return; /*if ( is_array(getArrayValue($master, 'ForeignKey')) ) { //if multiple ForeignKeys if ( $master['ForeignKey'][$parent_prefix] != end($master['ForeignKey']) ) {