[BUGFIX] Fix property access for ObjectStorage 14/31314/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Mon, 9 Jun 2014 10:02:51 +0000 (12:02 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 3 Jul 2014 16:49:51 +0000 (18:49 +0200)
When enabling access to the content of ObjectStorages by
integer number, it was overlooked that property access might
be desired too, which has also been working before.

Fix this by not aborting the access when addressing a
non-integer property on ObjectStorages.

Resolves: #59412
Releases: 6.3, 6.2
Change-Id: I59b83ed0bf0c965efcdf0aad9440d634953a221e
Reviewed-on: https://review.typo3.org/31314
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Reflection/ObjectAccess.php
typo3/sysext/extbase/Tests/Unit/Reflection/ObjectAccessTest.php

index 773a6e6..90d22fe 100644 (file)
@@ -112,9 +112,9 @@ class ObjectAccess {
                                        }
                                        $index++;
                                }
+                               $propertyExists = FALSE;
+                               return NULL;
                        }
-                       $propertyExists = FALSE;
-                       return NULL;
                } elseif ($subject instanceof \ArrayAccess && isset($subject[$propertyName])) {
                        return $subject[$propertyName];
                }
index e668554..57aff2a 100644 (file)
@@ -172,6 +172,16 @@ class ObjectAccessTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
+       public function getPropertyCanAccessPropertiesOfAnObjectStorageObject() {
+               $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
+               $objectStorage->key = 'value';
+               $actual = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($objectStorage, 'key');
+               $this->assertEquals('value', $actual, 'getProperty does not work with ObjectStorage property.');
+       }
+
+       /**
+        * @test
+        */
        public function getPropertyCanAccessPropertiesOfAnObjectImplementingArrayAccess() {
                $arrayAccessInstance = new \TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass(array('key' => 'value'));
                $actual = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($arrayAccessInstance, 'key');