From f530ef20c0f55cbc17f81d9f3468f6152c416341 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 29 May 2024 10:27:09 +0000
Subject: [PATCH] fixes #4228

Closes #4228

Merge request studip/studip!3059
---
 lib/flexi/PhpTemplate.php            | 15 +++++----------
 lib/flexi/Template.php               |  2 +-
 tests/unit/lib/flexi/FactoryTest.php |  2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/lib/flexi/PhpTemplate.php b/lib/flexi/PhpTemplate.php
index 8110b50dff5..4eb0da13114 100644
--- a/lib/flexi/PhpTemplate.php
+++ b/lib/flexi/PhpTemplate.php
@@ -17,20 +17,15 @@ class PhpTemplate extends Template
      * @return string A string representing the rendered presentation.
      * @throws TemplateNotFoundException
      */
-    public function _render(): string
+    protected function _render(): string
     {
         extract($this->get_attributes());
 
         # include template, parse it and get output
-        try {
-            ob_start();
-            require $this->template;
-            $content_for_layout = ob_get_contents();
-        } catch (\Error $e) {
-            throw new TemplateNotFoundException(previous: $e);
-        } finally {
-            ob_end_clean();
-        }
+        ob_start();
+        require $this->template;
+        $content_for_layout = ob_get_contents();
+        ob_end_clean();
 
         # include layout, parse it and get output
         if (isset($this->layout)) {
diff --git a/lib/flexi/Template.php b/lib/flexi/Template.php
index d5c0310c77b..44eefbe457a 100644
--- a/lib/flexi/Template.php
+++ b/lib/flexi/Template.php
@@ -18,7 +18,7 @@ abstract class Template
      *
      * @return string A string representing the rendered presentation.
      */
-    abstract public function _render(): string;
+    abstract protected function _render(): string;
 
     protected array $attributes = [];
     protected Template|null $layout = null;
diff --git a/tests/unit/lib/flexi/FactoryTest.php b/tests/unit/lib/flexi/FactoryTest.php
index 2df9f6aaae7..f8b9b8773a4 100644
--- a/tests/unit/lib/flexi/FactoryTest.php
+++ b/tests/unit/lib/flexi/FactoryTest.php
@@ -108,7 +108,7 @@ final class FactoryTestCase extends \Codeception\Test\Unit
     public function testShouldRespondToAddedHandlers()
     {
         $handler = new class('', $this->factory) extends Flexi\Template {
-            public function _render(): string
+            protected function _render(): string
             {
                 return '';
             }
-- 
GitLab