1627 - Ticket ref sometimes duplicate

This code is a drop in replacement based on  an abstract counter based on an abstract keyValue store.
The counter can be
 - class based (in this case the counter is initialized on max(id) + 1
 - key based (in this case the counter starts at 0)

Important: on both cases the counter is no more kept aligned with the primary key.

This lead to a MySQL8 compatible implementation.
This commit is contained in:
bruno DA SILVA
2019-10-31 11:12:15 +01:00
committed by OИUЯd da silva
parent c6f5b8b1f9
commit 57116ef054
2 changed files with 16 additions and 8 deletions

View File

@@ -203,12 +203,10 @@
public function DBInsertNoReload()
{
$oMutex = new iTopMutex('ticket_insert');
$oMutex->Lock();
$iNextId = MetaModel::GetNextKey(get_class($this));
$iNextId = ItopCounter::IncClass(get_class($this));
$sRef = $this->MakeTicketRef($iNextId);
$this->SetIfNull('ref', $sRef);
$iKey = parent::DBInsertNoReload();
$oMutex->Unlock();
return $iKey;
}
]]></code>