diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php index 42b876042a613a90a71e8b8868efb4e85e316834..11227d233c767c0240e89be2730787ab79510f2f 100644 --- a/lib/models/Courseware/StructuralElement.php +++ b/lib/models/Courseware/StructuralElement.php @@ -1045,9 +1045,7 @@ SQL; private function linkChildren(User $user, StructuralElement $newElement): void { - $children = self::findBySQL('parent_id = ?', [$this->id]); - - foreach ($children as $child) { + foreach ($this->children as $child) { $child->link($user, $newElement); } } @@ -1104,9 +1102,8 @@ SQL; private function getChildrenPdfExport(int $depth, bool $with_children, $user, $doc) { - $children = self::findBySQL('parent_id = ?', [$this->id]); $depth++; - foreach ($children as $child) { + foreach ($this->children as $child) { $child->getElementPdfExport($depth, $with_children, $user, $doc); } }