From 202123a18c3f1866c4096dc1821835f1cb04c1ae Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+github@gmail.com>
Date: Thu, 3 Mar 2022 14:07:02 +0100
Subject: [PATCH] ensure correct order, fixes #751

---
 app/controllers/my_courses.php | 2 +-
 lib/classes/MyRealmModel.php   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php
index 21cde0e1fdb..395bef9b02a 100644
--- a/app/controllers/my_courses.php
+++ b/app/controllers/my_courses.php
@@ -194,7 +194,6 @@ class MyCoursesController extends AuthenticatedController
                 'responsive_type'          => Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY && $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY_RESPONSIVE ? 'tiles' : 'tables',
                 'navigation_show_only_new' => $GLOBALS['user']->cfg->MY_COURSES_SHOW_NEW_ICONS_ONLY,
                 'group_by'                 => $this->getGroupField(),
-
             ],
         ];
 
@@ -1055,6 +1054,7 @@ class MyCoursesController extends AuthenticatedController
                 uksort($course['navigation'], function ($a, $b) use ($positions) {
                     return array_search($a, $positions) - array_search($b, $positions);
                 });
+                $course['navigation'] = array_values($course['navigation']);
                 return $course;
             },
             $courses
diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php
index 522dc8b766c..7421058bfdd 100644
--- a/lib/classes/MyRealmModel.php
+++ b/lib/classes/MyRealmModel.php
@@ -880,16 +880,16 @@ class MyRealmModel
      */
     public static function array_rtrim($array)
     {
-        $temp  = array_reverse($array);
+        $temp  = array_reverse($array, true);
         $empty = true;
 
         while ($empty && !empty($temp)) {
             $item = reset($temp);
             if ($empty = ($item === null)) {
-                $temp = array_slice($temp, 1);
+                $temp = array_slice($temp, 1, null, true);
             }
         }
-        return array_reverse($temp);
+        return array_reverse($temp, true);
     }
 
     /**
-- 
GitLab