Skip to content

Commit

Permalink
[BUGFIX] Prevent PHP errors in FileMount model
Browse files Browse the repository at this point in the history
This prevents an error triggered by accessing a possible
uninitialized property as well as a possible TypeError in
the newly introduced FileMount model.

Resolves: #99254
Related: #99038
Releases: main
Change-Id: I037ebd1322838f223ed19171b57118d039488936
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76888
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
  • Loading branch information
o-ba authored and sbuerk committed Dec 3, 2022
1 parent 765d5a8 commit 615fffa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions typo3/sysext/beuser/Classes/Domain/Model/FileMount.php
Expand Up @@ -38,7 +38,7 @@ class FileMount extends AbstractEntity
/**
* Description of the file mount.
*/
protected string $description;
protected string $description = '';

/**
* Identifier of the filemount
Expand Down Expand Up @@ -128,11 +128,13 @@ public function setHidden(bool $hidden): void
*/
public function getPath(): string
{
$segments = preg_split('#:/#', $this->identifier);
return $segments[1] ?? '';
return explode(':/', $this->identifier)[1] ?? '';
}

public function getStorage(): ResourceStorage
/**
* @todo This should be part of the ORM not the model class
*/
public function getStorage(): ?ResourceStorage
{
return GeneralUtility::makeInstance(StorageRepository::class)->findByCombinedIdentifier($this->identifier);
}
Expand Down

0 comments on commit 615fffa

Please sign in to comment.