From e9c9b571d7bd42d1228bb46470cc90632074537d Mon Sep 17 00:00:00 2001 From: Muhammad Shahrukh <> Date: Tue, 17 Sep 2024 13:35:53 +0500 Subject: [PATCH] NEUSPRT-266: Optimize log viewing for a contact Applying pr: https://github.com/civicrm/civicrm-core/pull/31125 --- CRM/Contact/Page/View/Log.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/Page/View/Log.php b/CRM/Contact/Page/View/Log.php index fd063213101f..13a9e578fd1f 100644 --- a/CRM/Contact/Page/View/Log.php +++ b/CRM/Contact/Page/View/Log.php @@ -33,6 +33,7 @@ public function browse() { } $log = new CRM_Core_DAO_Log(); + $modifiers = []; $log->entity_table = 'civicrm_contact'; $log->entity_id = $this->_contactId; @@ -41,11 +42,15 @@ public function browse() { $logEntries = []; while ($log->fetch()) { - [$displayName, $contactImage] = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); + if ($log->modified_id && !isset($modifiers[$log->modified_id])) { + $displayInfo = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); + $modifiers[$log->modified_id] = ['name' => $displayInfo[0] ?? '', 'image' => $displayInfo[1] ?? '']; + } + $logEntries[] = [ 'id' => $log->modified_id, - 'name' => $displayName, - 'image' => $contactImage, + 'name' => $log->modified_id && $modifiers[$log->modified_id]['name'] ? $modifiers[$log->modified_id]['name'] : '', + 'image' => $log->modified_id && $modifiers[$log->modified_id]['image'] ? $modifiers[$log->modified_id]['image'] : '', 'date' => $log->modified_date, ]; }