Project

General

Profile

Actions

Bug #100765

closed

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

Added by Kay Strobach over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Pagetree
Target version:
-
Start date:
2023-04-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Screenshot of the error

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:

  1. Migration
  2. Click the broken page
  3. see the error 503 in the backend

German Translation and Workaround:


Files

2023-04-26_14-02-06.png (155 KB) 2023-04-26_14-02-06.png Screenshot of the error Kay Strobach, 2023-04-26 12:43
2023-04-26_14-53-53.png (31.2 KB) 2023-04-26_14-53-53.png Kay Strobach, 2023-04-26 14:05
Actions #1

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.

Actions #2

Updated by Kay Strobach over 1 year ago

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.

Actions #3

Updated by Riccardo De Contardi about 1 year ago

  • Status changed from Needs Feedback to New
Actions #4

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.

Actions #5

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

Actions #6

Updated by Kay Strobach about 1 year ago

fine - please close it. PS: you selected the wrong kay in the @ mention :)

Actions #7

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

Actions

Also available in: Atom PDF