MDL-58964 navigation: Reindex array when element is removed

This commit is contained in:
Alexander Bias
2020-03-23 21:36:13 +01:00
parent cf0270260b
commit eaf3679e08
+4
View File
@@ -544,7 +544,11 @@ class navigation_node implements renderable {
if (in_array($class, $this->classes)) {
$key = array_search($class,$this->classes);
if ($key!==false) {
// Remove the class' array element.
unset($this->classes[$key]);
// Reindex the array to avoid failures when the classes array is iterated later in mustache templates.
$this->classes = array_values($this->classes);
return true;
}
}