From 02ec550c9e95845b9f59a093d94800268de190cc Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 2 Nov 2022 08:06:14 +0000
Subject: [PATCH] fix call to tabularasa action for institutes, fixes #1734

Closes #1734

Merge request studip/studip!1129
---
 app/controllers/my_institutes.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/app/controllers/my_institutes.php b/app/controllers/my_institutes.php
index 0bdff852d75..f61ad37d423 100644
--- a/app/controllers/my_institutes.php
+++ b/app/controllers/my_institutes.php
@@ -61,9 +61,15 @@ class MyInstitutesController extends AuthenticatedController
     public function tabularasa_action($timestamp = null)
     {
         $institutes = MyRealmModel::getMyInstitutes();
-        foreach ($institutes as $index => $institut) {
-            MyRealmModel::setObjectVisits($institutes[$index], $institut['institut_id'], $this->user_id, $timestamp);
-        }
+
+        // This is ugly but since the above does not return object, we need to
+        // load the institutes again
+        Institute::findEachMany(
+            function (Institute $institute) use ($timestamp) {
+                MyRealmModel::setObjectVisits($institute, $this->user_id, $timestamp);
+            },
+            array_column($institutes, 'institut_id')
+        );
 
         PageLayout::postSuccess(_('Alles als gelesen markiert!'));
         $this->redirect('my_institutes/index');
-- 
GitLab