MDL-73732 navigation: Do not assume output of find_active_node

When handling with the output of find_active_node,
proceed ahead only if the result is an instance of navigation_node.
Else there are chances of exceptions.
This commit is contained in:
Sujith Haridasan
2022-02-28 10:42:19 +05:30
parent 9cd77c4130
commit 8e6f807f9a
+5 -3
View File
@@ -4042,9 +4042,11 @@ class flat_navigation_node extends navigation_node {
if ($this->is_section()) {
$active = $PAGE->navigation->find_active_node();
while ($active = $active->parent) {
if ($active->key == $this->key && $active->type == $this->type) {
return true;
if ($active) {
while ($active = $active->parent) {
if ($active->key == $this->key && $active->type == $this->type) {
return true;
}
}
}
}