Index: branches/RC/core/kernel/utility/temp_handler.php =================================================================== diff -u -r9639 -r9643 --- branches/RC/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 9639) +++ branches/RC/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 9643) @@ -76,9 +76,9 @@ } } else { - $this->savedIDs[$prefix.($special ? '.' : '').$special][] = $id; + $this->savedIDs[$prefix.($special ? '.' : '').$special][] = $id; + } } - } /** * Get temp table name @@ -245,7 +245,7 @@ if (!preg_match('/(.*)-item$/', $special)) { $special .= '-item'; } - + $object =& $this->Application->recallObject($prefix.'.'.$special, $prefix, Array('skip_autoload' => true)); $object->PopulateMultiLangFields(); @@ -585,17 +585,19 @@ } else { // zero or negaitve ids should be copied one by one to get their InsertId // reseting to 0 so it get inserted into live table with autoincrement - $query = 'UPDATE '.$this->GetTempName($master['TableName']).' + $query = 'UPDATE '.$this->GetTempName($master['TableName']).' SET '.$master['IdField'].' = 0 WHERE '.$master['IdField'].' = '.$an_id; // constrain is not needed here because ID is already unique - $this->Conn->Query($query); + $this->Conn->Query($query); + // copying $query = 'INSERT INTO '.$master['TableName'].' SELECT * FROM '.$this->GetTempName($master['TableName']).' WHERE '.$master['IdField'].' = 0'; $this->Conn->Query($query); $live_ids[$an_id] = $this->Conn->getInsertID(); //storing newly created live id + //delete already copied record from master temp table $query = 'DELETE FROM '.$this->GetTempName($master['TableName']).' WHERE '.$master['IdField'].' = 0'; @@ -614,8 +616,6 @@ $this->saveID($master['Prefix'], '', $live_ids); - - // no need to clear temp table - it will be dropped by next statement } } @@ -716,7 +716,7 @@ array_push($this->DroppedTables, $table); $this->DroppedTables = array_unique($this->DroppedTables); $this->Conn->Query($query); - + return true; } @@ -743,10 +743,12 @@ } } } + function CheckSimultaniousEdit() { $tables = $this->Conn->GetCol('SHOW TABLES'); $mask_edit_table = '/'.TABLE_PREFIX.'ses_(.*)_edit_'.$this->MasterTable.'$/'; + $sql='SELECT COUNT(*) FROM '.$this->TableName.' WHERE '.$this->IDField.' = \'%s\''; $my_sid = $this->Application->GetSID(); $ids = join(',',$this->Tables['IDs']); @@ -760,6 +762,7 @@ if ($sid == $my_sid) continue; $found = $this->Conn->GetOne("SELECT COUNT({$this->Tables['IdField']}) FROM $table WHERE {$this->Tables['IdField']} IN ($ids)"); if (!$found || in_array($sid, $sids)) continue; + $sids[] = $sid; } }