N°5170 - In a transition DoCheckToWrite returned error, generes a Fatal error (#539)

This commit is contained in:
Anne-Catherine
2024-02-29 16:14:43 +01:00
committed by GitHub
parent 1a8de82be5
commit 5574952033
4 changed files with 36 additions and 7 deletions

View File

@@ -3592,16 +3592,26 @@ EOF
$oPage->add_ready_script(InlineImage::EnableCKEditorImageUpload($this, $sTempId));
} else {
//we can directly apply the stimuli
$sExceptionMessage = null;
try {
$bApplyStimulus = $this->ApplyStimulus($sStimulus); // will write the object in the DB
if (!$bApplyStimulus) {
throw new ApplicationException(Dict::S('UI:FailedToApplyStimuli'));
} else {
}
catch (Exception $oException) {
// Catch any exception happening during the stimulus
$bApplyStimulus = false;
$sExceptionMessage = ($oException instanceof CoreCannotSaveObjectException) ? $oException->getHtmlMessage() : $oException->getMessage();
}
finally {
if ($sOwnershipToken !== null) {
// Release the concurrent lock, if any
iTopOwnershipLock::ReleaseLock($sClass, $iKey, $sOwnershipToken);
}
return true;
if (!$bApplyStimulus) {
// Throw an application oriented exception if necessary
throw new ApplicationException($sExceptionMessage ?? Dict::S('UI:FailedToApplyStimuli'));
} else {
return true;
}
}
}

View File

@@ -1222,9 +1222,18 @@ class ObjectFormManager extends FormManager
}
}
}
catch (CoreCannotSaveObjectException $e) {
$aData['valid'] = false;
$aData['messages']['error'] += array('_main' => array($e->getHtmlMessage()));
if (false === $bExceptionLogged) {
IssueLog::Error(__METHOD__.' at line '.__LINE__.' : '.$e->getMessage());
}
}
catch (Exception $e) {
$aData['valid'] = false;
$aData['messages']['error'] += array('_main' => array($e->getMessage()));
$aData['messages']['error'] += [
'_main' => [ ($e instanceof CoreCannotSaveObjectException) ? $e->getHtmlMessage() : $e->getMessage()]
];
if (false === $bExceptionLogged) {
IssueLog::Error(__METHOD__.' at line '.__LINE__.' : '.$e->getMessage());
}

View File

@@ -333,6 +333,8 @@ class ObjectFormHandlerHelper
'modal' => true,
);
}
} else {
throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, implode('<br/>', $aFormData['validation']['messages']['error']['_main']));
}
break;

View File

@@ -1206,8 +1206,16 @@ try
$bApplyTransition = $oObj->DisplayStimulusForm($oP, $sStimulus, $aPrefillFormParam);
}
catch (ApplicationException $e) {
$bApplyTransition = false;
$sMessage = $e->getMessage();
$sSeverity = 'info';
$sSeverity = 'warning';
ReloadAndDisplay($oP, $oObj, 'stimulus', $sMessage, $sSeverity);
}
catch (CoreCannotSaveObjectException $e) {
$bApplyTransition = false;
$aIssues = $e->getIssues();
$sMessage = $e->getHtmlMessage();
$sSeverity = 'warning';
ReloadAndDisplay($oP, $oObj, 'stimulus', $sMessage, $sSeverity);
}
if ($bApplyTransition) {