From 1e71bc2c7b5e67d556fa4abc3c869b21a7a4f36e Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Thu, 14 Sep 2023 16:35:44 +0200 Subject: [PATCH] AdvMD: fix values being read out twice (37953) --- .../ActiveRecord/class.ilADTActiveRecordByType.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php b/Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php index 5efe7f06cba9..2e99e8d37c22 100644 --- a/Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php +++ b/Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php @@ -196,15 +196,18 @@ public function read(bool $a_return_additional_data = false) // read minimum tables foreach ($this->mapElementsToTables() as $table => $element_ids) { + $sub_table = ''; + $sub_tables = explode('_', $table); + if ($sub_tables !== false) { + $sub_table = array_pop($sub_tables); + } + if (isset(self::$preloaded[$sub_table]) && !$a_return_additional_data) { + continue; + } $sql = "SELECT * FROM " . $table . " WHERE " . $this->properties->buildPrimaryWhere(); $set = $this->db->query($sql); if ($this->db->numRows($set)) { - $sub_table = ''; - $sub_tables = explode('_', $table); - if ($sub_tables !== false) { - $sub_table = array_pop($sub_tables); - } while ($row = $this->db->fetchAssoc($set)) { $element_id = $row[$this->getElementIdColumn()]; if (in_array($element_id, $element_ids)) {