N°4756 - Ease extensibility for CRUD operations : 🎨 refactor after code review with PG

This commit is contained in:
Eric Espie
2023-01-26 17:32:02 +01:00
parent 5844717980
commit 1e37370789
13 changed files with 175 additions and 113 deletions

View File

@@ -4463,7 +4463,7 @@ HTML;
// Protection against reentrance (e.g. cascading the update of ticket logs)
// Note: This is based on the fix made on r 3190 in DBObject::DBUpdate()
if (!MetaModel::StartReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this)) {
if (!MetaModel::StartReentranceProtection($this)) {
$sClass = get_class($this);
$sKey = $this->GetKey();
IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey Rejected (reentrance)", LogChannels::DM_CRUD);
@@ -4482,7 +4482,7 @@ HTML;
}
finally
{
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
MetaModel::StopReentranceProtection($this);
}
$aChanges = $this->ListChanges();

View File

@@ -3064,29 +3064,32 @@ abstract class DBObject implements iDisplay
}
// Prevent DBUpdate at this point (reentrance protection)
MetaModel::StartReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
MetaModel::StartReentranceProtection($this);
$this->EventCreateDone();
$this->AfterInsert();
try {
$this->EventCreateDone();
$this->AfterInsert();
// Activate any existing trigger
$sClass = get_class($this);
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT TriggerOnObjectCreate AS t WHERE t.target_class IN (:class_list)'), array(), $aParams);
while ($oTrigger = $oSet->Fetch()) {
/** @var \Trigger $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
// Activate any existing trigger
$sClass = get_class($this);
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT TriggerOnObjectCreate AS t WHERE t.target_class IN (:class_list)'), array(), $aParams);
while ($oTrigger = $oSet->Fetch()) {
/** @var \Trigger $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
// - TriggerOnObjectMention
$this->ActivateOnMentionTriggers(true);
}
finally {
MetaModel::StopReentranceProtection($this);
}
// - TriggerOnObjectMention
$this->ActivateOnMentionTriggers(true);
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
if ($this->IsModified()) {
$this->DBUpdate();
@@ -3157,7 +3160,7 @@ abstract class DBObject implements iDisplay
// Protect against reentrance (e.g. cascading the update of ticket logs)
$sClass = get_class($this);
$sKey = $this->GetKey();
if (!MetaModel::StartReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this)) {
if (!MetaModel::StartReentranceProtection($this)) {
IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey Rejected (reentrance)", LogChannels::DM_CRUD);
return false;
@@ -3175,7 +3178,6 @@ abstract class DBObject implements iDisplay
if (count($aChanges) == 0)
{
// Attempting to update an unchanged object
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey Aborted (no change)", LogChannels::DM_CRUD);
return $this->m_iKey;
@@ -3387,10 +3389,10 @@ abstract class DBObject implements iDisplay
}
finally
{
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
MetaModel::StopReentranceProtection($this);
}
if ($this->IsModified() || $bModifiedByUpdateDone) {
if ($this->IsModified() || $bModifiedByUpdateDone) {
// Controlled reentrance
$this->DBUpdate();
}

View File

@@ -128,9 +128,17 @@ abstract class MetaModel
/** @var string */
protected static $m_sEnvironment = 'production';
public const REENTRANCE_TYPE_UPDATE = 'update';
protected static $m_aReentranceProtection = [];
/**
* Objects currently created/updated.
*
* if an object is already being updated, then this method will return this object instead of recreating a new one.
* At this point the method DBUpdate of a new object with the same class and id won't do anything due to reentrance protection,
* so to ensure that the potential modifications are correctly saved, the object currently being updated is returned.
* DBUpdate() method then will take care that all the modifications will be saved.
*
* [class][key] -> object
*/
protected static array $m_aReentranceProtection = [];
/**
* MetaModel constructor.
@@ -342,7 +350,7 @@ abstract class MetaModel
{
self::_check_subclass($sClass);
return $sClass::GetClassName($sClass);
return call_user_func([$sClass, 'GetClassName'], $sClass);
}
/**
@@ -426,7 +434,7 @@ abstract class MetaModel
{
self::_check_subclass($sClass);
return $sClass::GetClassDescription($sClass);
return call_user_func([$sClass, 'GetClassDescription'], $sClass);
}
/**
@@ -5118,9 +5126,9 @@ abstract class MetaModel
if (!empty(self::$m_sTablePrefix))
{
foreach(CMDBSource::EnumTables() as $sTable)
foreach(self::DBEnumTables() as $sTable)
{
// perform a case insensitive test because on Windows the table names become lowercase :-(
// perform a case-insensitive test because on Windows the table names become lowercase :-(
if (strtolower(substr($sTable, 0, strlen(self::$m_sTablePrefix))) == strtolower(self::$m_sTablePrefix))
{
CMDBSource::DropTable($sTable);
@@ -6833,7 +6841,7 @@ abstract class MetaModel
// DBUpdate() method then will take care that all the modifications will be saved.
if (array_key_exists($sClassAlias.'id', $aRow)) {
$iKey = $aRow[$sClassAlias."id"];
$oObject = self::GetReentranceObject(Metamodel::REENTRANCE_TYPE_UPDATE, $sClass, $iKey);
$oObject = self::GetReentranceObject($sClass, $iKey);
if ($oObject !== false) {
return $oObject;
}
@@ -7598,33 +7606,32 @@ abstract class MetaModel
return $oAttDef->GetStyle($sValue);
}
protected static function GetReentranceObject($sType, $sClass, $sKey)
protected static function GetReentranceObject($sClass, $sKey)
{
if (isset(self::$m_aReentranceProtection[$sType][$sClass][$sKey])) {
return self::$m_aReentranceProtection[$sType][$sClass][$sKey];
if (isset(self::$m_aReentranceProtection[$sClass][$sKey])) {
return self::$m_aReentranceProtection[$sClass][$sKey];
}
return false;
}
/**
* @param $sType
* @param \DBObject $oObject
*
* @return bool true if reentry possible
*/
public static function StartReentranceProtection($sType, DBObject $oObject)
public static function StartReentranceProtection(DBObject $oObject)
{
if (isset(self::$m_aReentranceProtection[$sType][get_class($oObject)][$oObject->GetKey()])) {
if (isset(self::$m_aReentranceProtection[get_class($oObject)][$oObject->GetKey()])) {
return false;
}
self::$m_aReentranceProtection[$sType][get_class($oObject)][$oObject->GetKey()] = $oObject;
self::$m_aReentranceProtection[get_class($oObject)][$oObject->GetKey()] = $oObject;
return true;
}
public static function StopReentranceProtection($sType, DBObject $oObject)
public static function StopReentranceProtection(DBObject $oObject)
{
if (isset(self::$m_aReentranceProtection[$sType][get_class($oObject)][$oObject->GetKey()])) {
unset(self::$m_aReentranceProtection[$sType][get_class($oObject)][$oObject->GetKey()]);
if (isset(self::$m_aReentranceProtection[get_class($oObject)][$oObject->GetKey()])) {
unset(self::$m_aReentranceProtection[get_class($oObject)][$oObject->GetKey()]);
}
}
}

View File

@@ -145,6 +145,10 @@ return array(
'CAS_Request_Exception' => $vendorDir . '/apereo/phpcas/source/CAS/Request/Exception.php',
'CAS_Request_MultiRequestInterface' => $vendorDir . '/apereo/phpcas/source/CAS/Request/MultiRequestInterface.php',
'CAS_Request_RequestInterface' => $vendorDir . '/apereo/phpcas/source/CAS/Request/RequestInterface.php',
'CAS_ServiceBaseUrl_AllowedListDiscovery' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/AllowedListDiscovery.php',
'CAS_ServiceBaseUrl_Base' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Base.php',
'CAS_ServiceBaseUrl_Interface' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Interface.php',
'CAS_ServiceBaseUrl_Static' => $vendorDir . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Static.php',
'CAS_Session_PhpSession' => $vendorDir . '/apereo/phpcas/source/CAS/Session/PhpSession.php',
'CAS_TypeMismatchException' => $vendorDir . '/apereo/phpcas/source/CAS/TypeMismatchException.php',
'CLILikeWebPage' => $baseDir . '/sources/Application/WebPage/CLILikeWebPage.php',
@@ -439,8 +443,10 @@ return array(
'Combodo\\iTop\\Service\\Events\\Description\\EventDataDescription' => $baseDir . '/sources/Application/Service/Events/Description/EventDataDescription.php',
'Combodo\\iTop\\Service\\Events\\Description\\EventDescription' => $baseDir . '/sources/Application/Service/Events/Description/EventDescription.php',
'Combodo\\iTop\\Service\\Events\\EventData' => $baseDir . '/sources/Application/Service/Events/EventData.php',
'Combodo\\iTop\\Service\\Events\\EventException' => $baseDir . '/sources/Application/Service/Events/EventException.php',
'Combodo\\iTop\\Service\\Events\\EventHelper' => $baseDir . '/sources/Application/Service/Events/EventHelper.php',
'Combodo\\iTop\\Service\\Events\\EventService' => $baseDir . '/sources/Application/Service/Events/EventService.php',
'Combodo\\iTop\\Service\\Events\\EventServiceLog' => $baseDir . '/sources/Application/Service/Events/EventServiceLog.php',
'Combodo\\iTop\\Service\\Events\\iEventServiceSetup' => $baseDir . '/sources/Application/Service/Events/iEventServiceSetup.php',
'Combodo\\iTop\\Service\\Links\\LinkSetDataTransformer' => $baseDir . '/sources/Service/Links/LinkSetDataTransformer.php',
'Combodo\\iTop\\Service\\Links\\LinkSetModel' => $baseDir . '/sources/Service/Links/LinkSetModel.php',

View File

@@ -510,6 +510,10 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
'CAS_Request_Exception' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/Exception.php',
'CAS_Request_MultiRequestInterface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/MultiRequestInterface.php',
'CAS_Request_RequestInterface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Request/RequestInterface.php',
'CAS_ServiceBaseUrl_AllowedListDiscovery' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/AllowedListDiscovery.php',
'CAS_ServiceBaseUrl_Base' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Base.php',
'CAS_ServiceBaseUrl_Interface' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Interface.php',
'CAS_ServiceBaseUrl_Static' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/ServiceBaseUrl/Static.php',
'CAS_Session_PhpSession' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/Session/PhpSession.php',
'CAS_TypeMismatchException' => __DIR__ . '/..' . '/apereo/phpcas/source/CAS/TypeMismatchException.php',
'CLILikeWebPage' => __DIR__ . '/../..' . '/sources/Application/WebPage/CLILikeWebPage.php',
@@ -804,8 +808,10 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
'Combodo\\iTop\\Service\\Events\\Description\\EventDataDescription' => __DIR__ . '/../..' . '/sources/Application/Service/Events/Description/EventDataDescription.php',
'Combodo\\iTop\\Service\\Events\\Description\\EventDescription' => __DIR__ . '/../..' . '/sources/Application/Service/Events/Description/EventDescription.php',
'Combodo\\iTop\\Service\\Events\\EventData' => __DIR__ . '/../..' . '/sources/Application/Service/Events/EventData.php',
'Combodo\\iTop\\Service\\Events\\EventException' => __DIR__ . '/../..' . '/sources/Application/Service/Events/EventException.php',
'Combodo\\iTop\\Service\\Events\\EventHelper' => __DIR__ . '/../..' . '/sources/Application/Service/Events/EventHelper.php',
'Combodo\\iTop\\Service\\Events\\EventService' => __DIR__ . '/../..' . '/sources/Application/Service/Events/EventService.php',
'Combodo\\iTop\\Service\\Events\\EventServiceLog' => __DIR__ . '/../..' . '/sources/Application/Service/Events/EventServiceLog.php',
'Combodo\\iTop\\Service\\Events\\iEventServiceSetup' => __DIR__ . '/../..' . '/sources/Application/Service/Events/iEventServiceSetup.php',
'Combodo\\iTop\\Service\\Links\\LinkSetDataTransformer' => __DIR__ . '/../..' . '/sources/Service/Links/LinkSetDataTransformer.php',
'Combodo\\iTop\\Service\\Links\\LinkSetModel' => __DIR__ . '/../..' . '/sources/Service/Links/LinkSetModel.php',

View File

@@ -102,7 +102,7 @@ class EventDescription
}
/**
* @param \Combodo\iTop\Service\Events\Description\EventDataDescription[]s $aEventDataDescription
* @param \Combodo\iTop\Service\Events\Description\EventDataDescription[] $aEventDataDescription
*/
public function SetEventDataDescription(array $aEventDataDescription): void
{

View File

@@ -17,10 +17,10 @@ namespace Combodo\iTop\Service\Events;
*/
class EventData
{
private $sEvent;
private string $sEvent;
private $mEventSource;
private $aEventData;
private $aCallbackData;
private array $aEventData;
private array $aCallbackData;
/**
* EventServiceData constructor.
@@ -44,7 +44,7 @@ class EventData
* @api
* @return string Event fired.
*/
public function GetEvent()
public function GetEvent(): string
{
return $this->sEvent;
}
@@ -59,11 +59,11 @@ class EventData
*/
public function Get($sParam)
{
if (is_array($this->aEventData) && isset($this->aEventData[$sParam])) {
if (isset($this->aEventData[$sParam])) {
return $this->aEventData[$sParam];
}
if (is_array($this->aCallbackData) && isset($this->aCallbackData[$sParam])) {
if (isset($this->aCallbackData[$sParam])) {
return $this->aCallbackData[$sParam];
}
@@ -97,7 +97,7 @@ class EventData
*/
public function SetCallbackData($aCallbackData)
{
$this->aCallbackData = $aCallbackData;
$this->aCallbackData = $aCallbackData ?? [];
}
/**

View File

@@ -0,0 +1,14 @@
<?php
/*
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Service\Events;
use Exception;
class EventException extends Exception
{
}

View File

@@ -6,46 +6,8 @@
namespace Combodo\iTop\Service\Events;
use IssueLog;
use LogChannels;
use utils;
class EventHelper
{
public static function Trace($sMessage)
{
IssueLog::Trace($sMessage, LogChannels::EVENT_SERVICE);
}
public static function Debug($sMessage, $sEvent, $sources)
{
$oConfig = utils::GetConfig();
$aLogEvents = $oConfig->Get('event_service.debug.filter_events');
$aLogSources = $oConfig->Get('event_service.debug.filter_sources');
if (is_array($aLogEvents)) {
if (!in_array($sEvent, $aLogEvents)) {
return;
}
}
if (is_array($aLogSources)) {
if (!self::MatchEventSource($aLogSources, $sources)) {
return;
}
}
IssueLog::Debug($sMessage, LogChannels::EVENT_SERVICE);
}
public static function Error($sMessage)
{
IssueLog::Error($sMessage, LogChannels::EVENT_SERVICE);
}
public static function Warning($sMessage)
{
IssueLog::Warning($sMessage, LogChannels::EVENT_SERVICE);
}
public static function MatchEventSource($srcRegistered, $srcEvent): bool
{
if (empty($srcRegistered)) {

View File

@@ -24,14 +24,14 @@ use utils;
* @api
* @since 3.1.0
*/
class EventService
final class EventService
{
/** @var array */
private static $aEventListeners = [];
private static array $aEventListeners = [];
/** @var int */
private static $iEventIdCounter = 0;
private static int $iEventIdCounter = 0;
/** @var array */
private static $aEventDescriptions = [];
private static array $aEventDescriptions = [];
/**
* Initialize the Event Service. This is called by iTop.
@@ -99,7 +99,7 @@ class EventService
$iTotalRegistrations += count($aEvent);
}
$sLogEventName = "$sEvent:".self::GetSourcesAsString($sEventSource);
EventHelper::Trace("Registering event '$sLogEventName' for '$sName' with id '$sId' (total $iTotalRegistrations)");
EventServiceLog::Trace("Registering event '$sLogEventName' for '$sName' with id '$sId' (total $iTotalRegistrations)");
return $sId;
}
@@ -125,40 +125,57 @@ class EventService
$sEvent = $oEventData->GetEvent();
if (!self::IsEventRegistered($sEvent)) {
$sError = "Fire event error: Event $sEvent is not registered";
EventHelper::Error($sError);
EventServiceLog::Error($sError);
throw new CoreException($sError);
}
$eventSource = $oEventData->GetEventSource();
$oKPI = new ExecutionKPI();
$sLogEventName = "$sEvent - ".self::GetSourcesAsString($eventSource).' '.json_encode($oEventData->GetEventData());
EventHelper::Trace("Fire event '$sLogEventName'");
EventServiceLog::Trace("Fire event '$sLogEventName'");
if (!isset(self::$aEventListeners[$sEvent])) {
EventHelper::Debug("No listener for '$sLogEventName'", $sEvent, $eventSource);
EventServiceLog::DebugEvent("No listener for '$sLogEventName'", $sEvent, $eventSource);
$oKPI->ComputeStats('FireEvent', $sEvent);
return;
}
$oLastException = null;
$sLastExceptionMessage = null;
foreach (self::GetListeners($sEvent, $eventSource) as $aEventCallback) {
if (!self::MatchContext($aEventCallback['context'])) {
continue;
}
$sName = $aEventCallback['name'];
EventHelper::Debug("Fire event '$sLogEventName' calling '$sName'", $sEvent, $eventSource);
EventServiceLog::DebugEvent("Fire event '$sLogEventName' calling '$sName'", $sEvent, $eventSource);
try {
$oEventData->SetCallbackData($aEventCallback['data']);
call_user_func($aEventCallback['callback'], $oEventData);
}
catch (Exception $e) {
EventHelper::Error("Event '$sLogEventName' for '$sName' id {$aEventCallback['id']} failed with error: ".$e->getMessage());
catch (EventException $e) {
EventServiceLog::Error("Event '$sLogEventName' for '$sName' id {$aEventCallback['id']} failed with blocking error: ".$e->getMessage());
throw $e;
}
catch (Exception $e) {
$sLastExceptionMessage = "Event '$sLogEventName' for '$sName' id {$aEventCallback['id']} failed with non-blocking error: ".$e->getMessage();
EventServiceLog::Error($sLastExceptionMessage);
$oLastException = $e;
}
}
EventHelper::Debug("End of event '$sLogEventName'", $sEvent, $eventSource);
EventServiceLog::DebugEvent("End of event '$sLogEventName'", $sEvent, $eventSource);
$oKPI->ComputeStats('FireEvent', $sEvent);
if (!is_null($oLastException)) {
throw $oLastException;
}
}
public static function GetListeners(string $sEvent, $eventSource)
/**
* @param string $sEvent
* @param $eventSource
*
* @return array
*/
public static function GetListeners(string $sEvent, $eventSource): array
{
$aListeners = [];
if (isset(self::$aEventListeners[$sEvent])) {
@@ -219,7 +236,7 @@ class EventService
if ($aEventCallback['id'] == $sId) {
$sName = self::$aEventListeners[$sEvent][$idx]['name'];
unset (self::$aEventListeners[$sEvent][$idx]);
EventHelper::Trace("Unregistered callback '$sName' id $sId' on event '$sEvent'");
EventServiceLog::Trace("Unregistered callback '$sName' id $sId' on event '$sEvent'");
return false;
}
@@ -228,7 +245,7 @@ class EventService
});
if (!$bRemoved) {
EventHelper::Trace("No registration found for callback '$sId'");
EventServiceLog::Trace("No registration found for callback '$sId'");
}
}
@@ -240,13 +257,13 @@ class EventService
public static function UnRegisterEventListeners(string $sEvent)
{
if (!isset(self::$aEventListeners[$sEvent])) {
EventHelper::Trace("No registration found for event '$sEvent'");
EventServiceLog::Trace("No registration found for event '$sEvent'");
return;
}
unset(self::$aEventListeners[$sEvent]);
EventHelper::Trace("Unregistered all the callbacks on event '$sEvent'");
EventServiceLog::Trace("Unregistered all the callbacks on event '$sEvent'");
}
/**
@@ -257,7 +274,7 @@ class EventService
self::$aEventListeners = [];
self::$aEventDescriptions = [];
self::$iEventIdCounter = 0;
EventHelper::Trace("Unregistered all events");
EventServiceLog::Trace("Unregistered all events");
}
/**
@@ -296,7 +313,7 @@ class EventService
$sModule = $oEventDescription->GetModule();
if (self::IsEventRegistered($sEvent)) {
$sPrevious = self::$aEventDescriptions[$sEvent]['module'];
EventHelper::Warning("The Event $sEvent defined by $sModule has already been defined in $sPrevious, check your delta");
EventServiceLog::Warning("The Event $sEvent defined by $sModule has already been defined in $sPrevious, check your delta");
return;
}
@@ -312,8 +329,11 @@ class EventService
* @param string $sClass
*
* @return array
* @throws \ReflectionException
* @throws \ReflectionException
* @throws \ReflectionException
*/
public static function GetEventsByClass(string $sClass)
public static function GetEventsByClass(string $sClass): array
{
$aRes = [];
$oClass = new ReflectionClass($sClass);

View File

@@ -0,0 +1,45 @@
<?php
/*
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Service\Events;
use IssueLog;
use LogChannels;
use utils;
class EventServiceLog extends IssueLog
{
const CHANNEL_DEFAULT = LogChannels::EVENT_SERVICE;
/**
* @param $sMessage
* @param $sEvent
* @param $sources
*
* @return void
* @throws \ConfigException
* @throws \CoreException
*/
public static function DebugEvent($sMessage, $sEvent, $sources)
{
$oConfig = utils::GetConfig();
$aLogEvents = $oConfig->Get('event_service.debug.filter_events');
$aLogSources = $oConfig->Get('event_service.debug.filter_sources');
if (is_array($aLogEvents)) {
if (!in_array($sEvent, $aLogEvents)) {
return;
}
}
if (is_array($aLogSources)) {
if (!EventHelper::MatchEventSource($aLogSources, $sources)) {
return;
}
}
static::Debug($sMessage);
}
}

View File

@@ -636,7 +636,7 @@ class DBObjectTest extends ItopDataTestCase
$oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey());
$this->assertNotEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId());
MetaModel::StartReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $oPerson);
MetaModel::StartReentranceProtection($oPerson);
$oPerson->Set('email', 'test1@combodo.com');
$oPerson->DBUpdate();
@@ -646,7 +646,7 @@ class DBObjectTest extends ItopDataTestCase
$oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey());
$this->assertEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId());
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $oPerson);
MetaModel::StopReentranceProtection($oPerson);
}
public function testObjectIsReadOnly()

View File

@@ -153,7 +153,7 @@ class DBObjectTest extends ItopDataTestCase
$oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey());
$this->assertNotEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId());
MetaModel::StartReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $oPerson);
MetaModel::StartReentranceProtection($oPerson);
$oPerson->Set('email', 'test1@combodo.com');
$oPerson->DBUpdate();
@@ -163,7 +163,7 @@ class DBObjectTest extends ItopDataTestCase
$oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey());
$this->assertEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId());
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $oPerson);
MetaModel::StopReentranceProtection($oPerson);
}
public function testObjectIsReadOnly()