From 0c274dc24512cb50d6a9295081e0181d5d28fc17 Mon Sep 17 00:00:00 2001 From: mjansen Date: Thu, 30 Apr 2026 11:54:42 +0200 Subject: [PATCH] [FIX] StudyProgramme: Make updating custom icon less fragile See: https://mantis.ilias.de/view.php?id=47411 --- .../classes/class.ilObjStudyProgramme.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php index 4cbe71d60e7d..cf7f7098b71a 100755 --- a/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php +++ b/components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php @@ -1607,10 +1607,17 @@ public function updateCustomIcon(): void if ($subtype && $subtype->getIconIdentifier()) { $src = $this->type_repository->getIconPathFS($subtype); + if ($src === null || $src === '') { + // The subtype references an icon id that no longer resolves to a file, so delete it + $customIcon->remove(); + return; + } //This is a horrible hack to allow Flysystem/LocalFilesystem to read the file. $tmp = 'ico_' . $this->getId(); - copy($src, \ilFileUtils::getDataDir() . '/temp/' . $tmp); + if (!copy($src, ilFileUtils::getDataDir() . '/temp/' . $tmp)) { + return; + } $customIcon->saveFromTempFileName($tmp); } else { @@ -1909,14 +1916,14 @@ public function statusToRepr(int $status): string public function hasContentPage(): bool { - return \ilContainerPage::_exists(self::CP_TYPE, $this->getId()); + return ilContainerPage::_exists(self::CP_TYPE, $this->getId()); } public function createContentPage(): void { if ($this->hasContentPage()) { - throw new \LogicException('will not create content page - it already exists.'); + throw new LogicException('will not create content page - it already exists.'); } - $new_page_object = new \ilContainerPage(); + $new_page_object = new ilContainerPage(); $new_page_object->setId($this->getId()); $new_page_object->setParentId($this->getId()); $new_page_object->createFromXML();