diff --git a/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php b/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php index 7c3fc38..28a219b 100644 --- a/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php +++ b/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php @@ -157,7 +157,7 @@ class ObjectStorage implements \Countable, \Iterator, \ArrayAccess, ObjectMonito * @return bool */ public function offsetExists($object) { - return isset($this->storage[spl_object_hash($object)]); + return is_object($object) && isset($this->storage[spl_object_hash($object)]); } /** diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php index 90390c4..8019ba6 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php @@ -105,6 +105,22 @@ class ObjectStorageTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { /** * @test */ + public function offsetExistsWorksWithEmptyStorageAndIntegerKey() { + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->assertEquals($objectStorage->offsetExists(0), FALSE); + } + + /** + * @test + */ + public function offsetExistsWorksWithEmptyStorageAndStringKey() { + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->assertEquals($objectStorage->offsetExists('0'), FALSE); + } + + /** + * @test + */ public function getInfoReturnsTheDataAssociatedWithTheCurrentIteratorEntry() { $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); $object1 = new \StdClass();