N°5951 - Fix crash when creating a user with a non valid password

/!\ Mind that this could have impact on DoCheckToWrite() overloads for people using \DBObject::GetKey() instead of \DBObject::IsNew()
This commit is contained in:
Molkobain
2023-02-13 20:22:39 +01:00
parent b97a464bb1
commit 33717b9610
2 changed files with 6 additions and 10 deletions

View File

@@ -2971,11 +2971,6 @@ abstract class DBObject implements iDisplay
$this->DoComputeValues();
$this->OnInsert();
if ($this->m_iKey < 0) {
// This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it!
$this->m_iKey = null;
}
// If not automatically computed, then check that the key is given by the caller
if (!MetaModel::IsAutoIncrementKey($sRootClass)) {
if (empty($this->m_iKey)) {
@@ -2987,6 +2982,12 @@ abstract class DBObject implements iDisplay
if (!$bRes) {
throw new CoreCannotSaveObjectException(array('issues' => $aIssues, 'class' => get_class($this), 'id' => $this->GetKey()));
}
if ($this->m_iKey < 0) {
// This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it!
$this->m_iKey = null;
}
$this->ComputeStopWatchesDeadline(true);
$iTransactionRetry = 1;

View File

@@ -278,11 +278,6 @@ JS;
$aResult['data'] = ['error_message' => $e->getHtmlMessage()];
} else {
$sClassLabel = MetaModel::GetName($sClass);
$sClassIcon = MetaModel::GetClassIcon($sClass);
$sHeaderTitle = Dict::Format('UI:CreationTitle_Class', $sClassLabel);
// Important: This is a temporary fix for N°5951, we need to discuss the DBObject::DBInsertNoReload() sequence before going further
$oObj->SetKey(-1);
$oPage->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel));
if (!empty($aIssues)) {