diff --git a/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php b/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php index 3c70da18104b32a9060ff0794569ba071886fe44..4cc5a6d95701c5744494712aa33c941f25380701 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 90390c47f1e60d412c413b0cf784ce594bf6c565..8019ba6d6e2ce59706dfd4d09e8c76c1a3a17d99 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/ObjectStorageTest.php @@ -102,6 +102,22 @@ class ObjectStorageTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { $this->assertEquals($objectStorage->offsetExists($object2), FALSE); } + /** + * @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 */