Issue Bug Closed

#50802FolderBasedFileCollection::loadContents() doesn't check if folder is present

Frans Saris 08/05/13, 22:08 updated 10/02/18, 12:12

Description

in FolderBasedFileCollection::loadContents() there is no check if the folder object is present this can result in a fatal error.

    Call to a member function getFiles() on a non-object in typo3/sysext/core/Classes/Resource/Collection/FolderBasedFileCollection.php on line 73

*example usage:

            /** @var $fileCollection \TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection */
            $fileCollection = $this->fileCollectionRepository->findByUid($this->getUid());
            $fileCollection->loadContents();
            $this->assets = $fileCollection->getItems();

There is no way to check if the initialization of the object was successful so you currently can not prevent the error.

Fix:
Check in FolderBasedFileCollection::loadContents() if $this->folder is initialized.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.