From 3d8fe9d90ee7d6ab60defb7d762a1ee160292919 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Wed, 3 Apr 2024 16:42:18 +0200 Subject: [PATCH] fix: [analyst-data:attachData] Make sure to also load child notes and opinions Changed the old behavior: Before we were loading 3 children. Now, we only load 1 by default. --- app/Model/AnalystData.php | 2 ++ app/Model/Behavior/AnalystDataParentBehavior.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/app/Model/AnalystData.php b/app/Model/AnalystData.php index 9266c72e9..1e1d0620c 100644 --- a/app/Model/AnalystData.php +++ b/app/Model/AnalystData.php @@ -377,6 +377,8 @@ class AnalystData extends AppModel return $analystData; } $this->fetchedUUIDFromRecursion[$analystData['uuid']] = true; + $this->Note = ClassRegistry::init('Note'); + $this->Opinion = ClassRegistry::init('Opinion'); $paramsNote = [ 'recursive' => -1, diff --git a/app/Model/Behavior/AnalystDataParentBehavior.php b/app/Model/Behavior/AnalystDataParentBehavior.php index 6977669e4..729cd2455 100644 --- a/app/Model/Behavior/AnalystDataParentBehavior.php +++ b/app/Model/Behavior/AnalystDataParentBehavior.php @@ -31,6 +31,9 @@ class AnalystDataParentBehavior extends ModelBehavior $temp = $this->{$type}->fetchForUuid($object['uuid'], $this->__currentUser); if (!empty($temp)) { foreach ($temp as $k => $temp_element) { + if (in_array($type, ['Note', 'Opinion', 'Relationship'])) { + $temp_element[$type] = $this->{$type}->fetchChildNotesAndOpinions($this->__currentUser, $temp_element[$type], 1); + } $data[$type][] = $temp_element[$type]; } }