From 12ded633b497fdc17bb173f4cef060be86ddc0e0 Mon Sep 17 00:00:00 2001 From: Peter Dias Date: Thu, 18 Nov 2021 11:17:00 +0800 Subject: [PATCH] MDL-72934 core_navigation: Early return if no nodes to be rendered. Do not export any items for templates if the nodecollection does not have any children. --- lib/classes/navigation/output/more_menu.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/classes/navigation/output/more_menu.php b/lib/classes/navigation/output/more_menu.php index 4c8fb915481..334671eb742 100644 --- a/lib/classes/navigation/output/more_menu.php +++ b/lib/classes/navigation/output/more_menu.php @@ -57,8 +57,9 @@ class more_menu implements renderable, templatable { public function export_for_template(renderer_base $output): array { $data = ['navbarstyle' => $this->navbarstyle]; if ($this->haschildren) { + // The node collection doesn't have anything to render so exit now. if (!isset($this->content->children) || count($this->content->children) == 0) { - $data = []; + return []; } $data['nodecollection'] = $this->content; } else {