From cae6febc3efa76da31d581b4bc52e4afb494a254 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 20 Mar 2023 14:11:35 +0000
Subject: [PATCH] prevent php8 warnings, fixes #2401

Closes #2401

Merge request studip/studip!1594
---
 lib/messaging.inc.php | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/messaging.inc.php b/lib/messaging.inc.php
index d0fe68e5091..b055c7f1a13 100644
--- a/lib/messaging.inc.php
+++ b/lib/messaging.inc.php
@@ -186,6 +186,7 @@ class messaging
             $reply_to = $sender->Email;
         }
         $attachments = [];
+        $attachments_as_links = false;
         if ($GLOBALS['ENABLE_EMAIL_ATTACHMENTS'] && $msg->attachment_folder) {
             $attachments = $msg->attachment_folder->file_refs;
             $size_of_attachments = array_sum($attachments->pluck('size')) ?: 0;
@@ -357,10 +358,16 @@ class messaging
         // diese user_id schreiben wir in ein tempraeres array
         foreach ($rec_id as $one) {
             $smsforward_rec = User::find($one)->smsforward_rec;
-            $tmp_forward_id = User::find($smsforward_rec)->user_id;
-            if ($tmp_forward_id) {
-                $rec_id[] = $tmp_forward_id;
+            if (!$smsforward_rec) {
+                continue;
             }
+
+            $tmp_forward = User::find($smsforward_rec);
+            if (!$tmp_forward) {
+                continue;
+            }
+
+            $rec_id[] = $tmp_forward->id;
         }
 
         // wir mergen die eben erstellten arrays und entfernen doppelte eintraege
-- 
GitLab