From e70e9de1c8387237301e5abb60360e9f68005a36 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Mon, 31 Oct 2022 12:15:52 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04756=20-=20restrict=20readonly=20mode=20?= =?UTF-8?q?to=20events=20only=20for=20CheckToWrite=20(keep=20legacy=20call?= =?UTF-8?q?s=20unprotected)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index d21860650..e286f23ba 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2339,7 +2339,7 @@ abstract class DBObject implements iDisplay * @throws \OQLException * */ - public function CheckToWrite($bDoComputeValues = true) + public final function CheckToWrite($bDoComputeValues = true) { if (MetaModel::SkipCheckToWrite()) { @@ -2353,8 +2353,11 @@ abstract class DBObject implements iDisplay if ($bDoComputeValues) { $this->DoComputeValues(); } - // Event before the legacy callback + + $this->SetReadOnly('No modification allowed during CheckToWrite'); $this->EventCheckToWrite(['error_messages' => &$this->m_aCheckIssues]); + $this->SetReadWrite(); + $this->DoCheckToWrite(); $oKPI->ComputeStats('CheckToWrite', get_class($this)); if (count($this->m_aCheckIssues) == 0) @@ -2980,9 +2983,7 @@ abstract class DBObject implements iDisplay } // Ultimate check - ensure DB integrity - $this->SetReadOnly('No modification allowed during CheckToWrite'); list($bRes, $aIssues) = $this->CheckToWrite(false); - $this->SetReadWrite(); if (!$bRes) { throw new CoreCannotSaveObjectException(array('issues' => $aIssues, 'class' => get_class($this), 'id' => $this->GetKey())); }