Skip to content

Commit 63a05d1

Browse files
[FIX] StudyProgramme: Make updating custom icon less fragile (#11505)
See: https://mantis.ilias.de/view.php?id=47411
1 parent c7db83b commit 63a05d1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

components/ILIAS/StudyProgramme/classes/class.ilObjStudyProgramme.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,10 +1610,17 @@ public function updateCustomIcon(): void
16101610

16111611
if ($subtype && $subtype->getIconIdentifier()) {
16121612
$src = $this->type_repository->getIconPathFS($subtype);
1613+
if ($src === null || $src === '') {
1614+
// The subtype references an icon id that no longer resolves to a file, so delete it
1615+
$customIcon->remove();
1616+
return;
1617+
}
16131618

16141619
//This is a horrible hack to allow Flysystem/LocalFilesystem to read the file.
16151620
$tmp = 'ico_' . $this->getId();
1616-
copy($src, \ilFileUtils::getDataDir() . '/temp/' . $tmp);
1621+
if (!copy($src, ilFileUtils::getDataDir() . '/temp/' . $tmp)) {
1622+
return;
1623+
}
16171624

16181625
$customIcon->saveFromTempFileName($tmp);
16191626
} else {
@@ -1912,14 +1919,14 @@ public function statusToRepr(int $status): string
19121919

19131920
public function hasContentPage(): bool
19141921
{
1915-
return \ilContainerPage::_exists(self::CP_TYPE, $this->getId());
1922+
return ilContainerPage::_exists(self::CP_TYPE, $this->getId());
19161923
}
19171924
public function createContentPage(): void
19181925
{
19191926
if ($this->hasContentPage()) {
1920-
throw new \LogicException('will not create content page - it already exists.');
1927+
throw new LogicException('will not create content page - it already exists.');
19211928
}
1922-
$new_page_object = new \ilContainerPage();
1929+
$new_page_object = new ilContainerPage();
19231930
$new_page_object->setId($this->getId());
19241931
$new_page_object->setParentId($this->getId());
19251932
$new_page_object->createFromXML();

0 commit comments

Comments
 (0)