Bug #100765
closedTYPO3\CMS\Core\Resource\File::__construct(): Argument #2 ($storage) must be of type TYPO3\CMS\Core\Resource\ResourceStorage, null given, called in /var/www/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3217
0%
Description
After an Upgrade from TYPO3 v9 to v11 (over 10) a customer reported the following error:
TYPO3\CMS\Core\Resource\File::__construct(): Argument #2 ($storage) must be of type TYPO3\CMS\Core\Resource\ResourceStorage, null given, called in /var/www/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3217
As the installation was a SaaS one, i had no chance to enable debug mode, nor to get more info regarding the database content.
Related Problems, when the broken page is selected:
- Page > Web not accessible
- Page > List not accessible
- Page > Info not accessible
- Page > View not accessible
- Page > Trash not accessible
- Page > Template not accessible
- Page > Template not accessible
Steps to reproduce:
- Migration
- Click the broken page
- see the error 503 in the backend
German Translation and Workaround:
- https://drk-intern.gitlab.io/typo3-main-distribution/11-Nachschlagen/Fehler503BackendStorage/Index.html
- You may duplicate the page with the edit form action, the resulting page is working and can replace the original page
Files
Updated by Andreas Kienast over 1 year ago
- Status changed from New to Needs Feedback
Do you have anything in your log file? Without a stack trace, it's nearly impossible to analyze this issue.
Updated by Kay Strobach over 1 year ago
- File 2023-04-26_14-53-53.png 2023-04-26_14-53-53.png added
Dear Andreas,
sure, i tried to get it and still communicate with the operator of the instance to get more insights.
I would also have supplied a patch as it seems to be a call to the FileRepository, which returns a file without as storage, which is then used to create a file.
I believe it's a problem here:
public function createFileObject(array $fileData, ResourceStorage $storage = null)
{
if (array_key_exists('storage', $fileData) && MathUtility::canBeInterpretedAsInteger($fileData['storage'])) {
$storageObject = $this->storageRepository->findByUid((int)$fileData['storage']);
} elseif ($storage !== null) {
$storageObject = $storage;
$fileData['storage'] = $storage->getUid();
} else {
throw new \RuntimeException('A file needs to reside in a Storage', 1381570997);
}
$fileObject = GeneralUtility::makeInstance(File::class, $fileData, $storageObject);
return $fileObject;
}
Should be something like that to ensure a set, but not existing storage is not causing a problem.
public function createFileObject(array $fileData, ResourceStorage $storage = null)
{
$storageObject = null;
if (array_key_exists('storage', $fileData) && MathUtility::canBeInterpretedAsInteger($fileData['storage'])) {
$storageObject = $this->storageRepository->findByUid((int)$fileData['storage']);
} elseif ($storage !== null) {
$storageObject = $storage;
$fileData['storage'] = $storage->getUid();
}
if($storageObject === null) {
throw new \RuntimeException('A file needs to reside in a Storage', 1381570997);
}
$fileObject = GeneralUtility::makeInstance(File::class, $fileData, $storageObject);
return $fileObject;
}
As for now, I have no access to the full DB dump, nor to the logfile, the above point was one way to reproduce the behaviour.
I'm also trying wether the cronjobs to clean the DB solve that problem with shipped tooling.
Updated by Riccardo De Contardi about 1 year ago
- Status changed from Needs Feedback to New
Updated by Kay Strobach about 1 year ago
Unsure, never had that again - fixed it for the customer by copying the page. might get closed - workaround is described in the external liked website.
Updated by Riccardo De Contardi about 1 year ago
@Kay Strobach thank you for your quick feedback, so if you agree, I will close it.
Thanks again and sorry for the late reply
Updated by Kay Strobach about 1 year ago
fine - please close it. PS: you selected the wrong kay in the @ mention :)
Updated by Riccardo De Contardi about 1 year ago
- Status changed from New to Closed
- Target version deleted (
Candidate for patchlevel)
Kay Strobach wrote in #note-6:
fine - please close it. PS: you selected the wrong kay in the @ mention :)
Fixed. Blame the Forge autocomplete of names :P
Thank you for your feedback - closing it
If you think that this is the wrong decision or experience the issue again please open a fresh issue with a reference to this one