Index: branches/5.3.x/core/kernel/utility/temp_handler.php =================================================================== diff -u -N -r16390 -r16503 --- branches/5.3.x/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 16390) +++ branches/5.3.x/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 16503) @@ -1,6 +1,6 @@ _getSeparateConnection(); + $master_ids = $this->_tables->parseTempIds($master_ids); do { // acquire lock $conn->ChangeQuery('LOCK TABLES ' . TABLE_PREFIX . 'Semaphores WRITE'); - $sql = 'SELECT SessionKey + $another_coping_active = false; + $sql = 'SELECT MainIDs FROM ' . TABLE_PREFIX . 'Semaphores - WHERE (MainPrefix = ' . $conn->qstr($this->_tables->getPrefix()) . ')'; - $another_coping_active = $conn->GetOne($sql); + WHERE MainPrefix = ' . $conn->qstr($this->_tables->getPrefix()) . ' AND MainIDs <> "0"'; + $other_semaphores_main_ids = $conn->GetCol($sql); + foreach ( $other_semaphores_main_ids as $other_semaphore_main_ids ) { + $other_semaphore_main_ids = explode(',', $other_semaphore_main_ids); + + if ( array_intersect($master_ids, $other_semaphore_main_ids) ) { + $another_coping_active = true; + break; + } + } + if ( $another_coping_active ) { // another user is coping data from temp table to live -> release lock and try again after 1 second $conn->ChangeQuery('UNLOCK TABLES'); @@ -145,6 +156,7 @@ 'SessionKey' => $this->Application->GetSID(), 'Timestamp' => time(), 'MainPrefix' => $this->_tables->getPrefix(), + 'MainIDs' => implode(',', $master_ids), ); $conn->doInsert($fields_hash, TABLE_PREFIX . 'Semaphores'); @@ -1391,6 +1403,18 @@ } /** + * Ensures, that ids are always an array + * + * @param array $ids IDs. + * + * @return array + */ + public function parseTempIds($ids) + { + return $this->_parseTempIds($ids); + } + + /** * Checks, that someone is editing selected records and returns true, when no one. * * @param Array $ids