From 558bbc3357e8c2afbdb8b09ac3ae87fb2cfafb2d Mon Sep 17 00:00:00 2001 From: Molkobain Date: Sun, 6 Mar 2022 17:20:28 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"N=C2=B04911=20-=20Mentions:=20Fix=20P?= =?UTF-8?q?erson=20picture=20not=20displayed=20if=20marker=20configured=20?= =?UTF-8?q?on=20parent=20class=20(Contact)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 106127e6b76582955d966ee82ff7ff1ea060aa17. As the image attribute can be different depending on the object finalclass, it cannot be added in the DBObjectSet::OptimizeColumnLoad(), which means that retrieving it within the loop might lead to a complete DBObject::Reload() of the object which can have a real impact on performances depending on the objects. --- pages/ajax.render.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index db3e34c24..bf3a5cb24 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -2507,6 +2507,8 @@ EOF $sSearchMainClassName = $oSearch->GetClass(); $sSearchMainClassAlias = $oSearch->GetClassAlias(); + $sObjectImageAttCode = MetaModel::GetImageAttributeCode($sSearchMainClassName); + // Add condition to filter on the friendlyname $oSearch->AddConditionExpression( new BinaryExpression(new FieldExpression('friendlyname', $sSearchMainClassAlias), 'LIKE', new VariableExpression('needle')) @@ -2519,7 +2521,7 @@ EOF $oSet->SetShowObsoleteData(utils::ShowObsoleteData()); while ($oObject = $oSet->Fetch()) { - // Note: $oObject finalclass might be different than $sMentionedClass + // Note $oObject finalclass might be different than $sMentionedClass $sObjectClass = get_class($oObject); $iObjectId = $oObject->GetKey(); $aMatch = [ @@ -2528,8 +2530,7 @@ EOF 'friendlyname' => $oObject->Get('friendlyname'), ]; - // Try to retrieve image for object (Don't do it outside of the loop as $oObject can be from different classes) - $sObjectImageAttCode = MetaModel::GetImageAttributeCode($sObjectClass); + // Try to retrieve image for contact if (!empty($sObjectImageAttCode)) { /** @var \ormDocument $oImage */ $oImage = $oObject->Get($sObjectImageAttCode);