From fd65f4d4114f421958b2f6fa9d045039bc865d8b Mon Sep 17 00:00:00 2001
From: Thomas Hackl <hackl@data-quest.de>
Date: Wed, 12 Feb 2025 12:51:12 +0100
Subject: [PATCH] PHP8: properly initialize all values for view

---
 controllers/matrix_chat.php |  7 ++++---
 views/matrix_chat/index.php | 11 +++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/controllers/matrix_chat.php b/controllers/matrix_chat.php
index 5c1507f..ffe3f43 100644
--- a/controllers/matrix_chat.php
+++ b/controllers/matrix_chat.php
@@ -41,6 +41,10 @@ class MatrixChatController extends AuthenticatedController
         Navigation::activateItem('/course/matrix/matrix_chat');
 
         $this->noChat = false;
+        $this->noMemberHint = false;
+        $this->showAccountHint = false;
+        $this->account = null;
+        $this->hasToCreate = false;
 
         $member = CourseMember::find([$this->course->id, User::findCurrent()->id]);
 
@@ -71,13 +75,10 @@ class MatrixChatController extends AuthenticatedController
                 $this->account->store();
             }
 
-            $this->hasToCreate = false;
             if ($this->account || !Config::get()->MATRIX_AUTO_CREATE_ACCOUNTS) {
                 if (!($room = MatrixRoom::findOneByRange_id(Course::findCurrent()->id))) {
                     $this->hasToCreate = true;
                 } else {
-                    $this->hasToCreate = false;
-
                     if ($this->account) {
                         if (Config::get()->MATRIX_AUTO_CREATE_ACCOUNTS) {
                             $room->requireMembership($this->account->getLinkedAccount());
diff --git a/views/matrix_chat/index.php b/views/matrix_chat/index.php
index 5662ea8..dcaaf72 100644
--- a/views/matrix_chat/index.php
+++ b/views/matrix_chat/index.php
@@ -1,3 +1,14 @@
+<?php
+/**
+ * @var bool $noMemberHint
+ * @var bool $showAccountHint
+ * @var MatrixAccount $account
+ * @var MatrixChatController $controller
+ * @var bool $no_account_wanted
+ * @var bool $hasToCreate
+ * @var bool $noChat
+ */
+?>
 <? if ($noMemberHint) : ?>
     <div class="messagebox messagebox_warning">
         <p>
-- 
GitLab