mirror of
https://github.com/Combodo/iTop.git
synced 2026-08-15 02:08:20 +02:00
N°4173 Fix memory_limit error when saving an object pointing to a big AttributeBlob
Check of pointed object was loading the whole object instead of just doing a count
This commit is contained in:
@@ -1859,9 +1859,7 @@ abstract class DBObject implements iDisplay
|
||||
{
|
||||
/** @var \AttributeExternalKey $oAtt */
|
||||
$sTargetClass = $oAtt->GetTargetClass();
|
||||
$oTargetObj = MetaModel::GetObject($sTargetClass, $toCheck, false /*must be found*/, true /*allow all data*/);
|
||||
if (is_null($oTargetObj))
|
||||
{
|
||||
if (false === MetaModel::IsObjectExistsInDb($sTargetClass, $toCheck)) {
|
||||
return "Target object not found ($sTargetClass::$toCheck)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6976,12 +6976,9 @@ abstract class MetaModel
|
||||
|
||||
if (!utils::IsArchiveMode() && $oObject->IsArchived())
|
||||
{
|
||||
if ($bMustBeFound)
|
||||
{
|
||||
if ($bMustBeFound) {
|
||||
throw new ArchivedObjectException("The object $sClass::$iKey is archived");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6989,6 +6986,15 @@ abstract class MetaModel
|
||||
return $oObject;
|
||||
}
|
||||
|
||||
public static function IsObjectExistsInDb(string $sClass, int $iKey): bool
|
||||
{
|
||||
$oFilter = DBObjectSearch::FromOQL('SELECT '.$sClass.' WHERE id = :id', ['id' => $iKey,]);
|
||||
$oSet = new DBObjectSet($oFilter);
|
||||
$iCount = $oSet->Count();
|
||||
|
||||
return ($iCount > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the specified class and id. If the object is archived it will be returned anyway (this is for pre-2.4
|
||||
* module compatibility, see N.1108)
|
||||
|
||||
Reference in New Issue
Block a user