diff --git a/typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php b/typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php index 2b890c94a76725b01961db665f32ffb0a4876dc2..6d5d422ccc9080258609d66c8587279896881f75 100644 --- a/typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php +++ b/typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php @@ -116,6 +116,14 @@ class CategoryCollection extends AbstractRecordCollection implements EditableCol ->executeQuery() ->fetchAssociative(); + if ($collectionRecord === false) { + return GeneralUtility::makeInstance( + self::class, + $tableName, + $fieldName + ); + } + $collectionRecord['table_name'] = $tableName; $collectionRecord['field_name'] = $fieldName; diff --git a/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php b/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php index e00c3a5e107d8c6eff3f717a5eb6ba3898bc7ef6..d436452b6882f48ec4b562eb050031292f259409 100644 --- a/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php +++ b/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php @@ -152,6 +152,14 @@ final class CategoryCollectionTest extends FunctionalTestCase self::assertEquals(0, $collection->count()); } + #[Test] + public function canLoadADummyCollectionFromNotExistingCategory(): void + { + $collection = CategoryCollection::load(-1, false, 'tx_test_test'); + // Check the number of record + self::assertEquals(0, $collection->count()); + } + #[Test] public function canLoadADummyCollectionFromDatabaseAfterRemoveOneRelation(): void {