From a88c414c360d0a6cfd2408b5556bafa6af7a9e59 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 31 Jul 2023 17:05:53 +0000
Subject: [PATCH] FileArchiveManager::addFileTypeToArchive: call
 convertToStandardFile on files that aren't StandardFile instances before
 requesting their path, re #2987

Merge request studip/studip!2003
---
 lib/filesystem/FileArchiveManager.class.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/filesystem/FileArchiveManager.class.php b/lib/filesystem/FileArchiveManager.class.php
index 36ea988d8b4..e7a0d40581c 100644
--- a/lib/filesystem/FileArchiveManager.class.php
+++ b/lib/filesystem/FileArchiveManager.class.php
@@ -131,6 +131,14 @@ class FileArchiveManager
                     return true;
                 }
             } else {
+                if (!($file_type instanceof StandardFile)) {
+                    $file_type = $file_type->convertToStandardFile();
+                }
+                if (!($file_type instanceof StandardFile)) {
+                    //The file type could not be converted to a standard file.
+                    //We cannot continue.
+                    return false;
+                }
                 //Get the file's path (if the file exists) and add the file to the archive:
                 $path = $file_type->getPath();
                 if ($path) {
-- 
GitLab