From f15bdb75ca3bfa860dfd945532e969b31c82f96e Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 30 Jul 2021 16:46:53 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04173=20Fix=20memory=5Flimit=20error=20on?= =?UTF-8?q?=20target=20object=20hyperlink=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index d9185af11..b4bea3cfb 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -1277,13 +1277,20 @@ abstract class DBObject implements iDisplay { // If the object if not issued from a query but constructed programmatically // the label may be empty. In this case run a query to get the object's friendly name - $oTmpObj = MetaModel::GetObject($sObjClass, $sObjKey, false); - if (is_object($oTmpObj)) - { + $sObjOql = 'SELECT '.$sObjClass.' WHERE id='.$sObjKey; + $oObjFilter = DBSearch::FromOQL($sObjOql); + $oSet = new DBObjectSet($oObjFilter); + + // we will only use id and friendlyname, so let's remove other fields ! + $aAttToLoad = [ + $sObjClass => [], + ]; + $oSet->OptimizeColumnLoad($aAttToLoad); + + $oTmpObj = $oSet->Fetch(); + if (is_object($oTmpObj)) { $sHtmlLabel = $oTmpObj->GetName(); - } - else - { + } else { // May happen in case the target object is not in the list of allowed values for this attribute $sHtmlLabel = "$sObjClass::$sObjKey"; }