Review main Merged

29923[BUGFIX] Make object access work with ObjectStorage

Helmut Hummel CR +2 V +2 Normal +42 −21 updated 06/02/14, 16:29

Commit message

ObjectAccess->getPropertyPath() does not work with
ObjectStorage and numerical indexes, but it should be
because without it form fluid fields cannot be
properly handled as the value is always null.

Fixing fetching objects from ObjectStorage by index
will also enable shorter access of single objects in Fluid.

Imagine you want to render the first image in your
template. Previously you had to write this:

<f:for each="{object.images}" as="image" iteration="iterator">
	<f:if condition="{iterator.isFirst}">
		<f:image image="{image}" alt="" width="50"/>
	</f:if>
</f:for>

Now you can just write:

<f:image image="{object.images.0}" alt="" width="50"/>

Review

  • Code review CR +2
    • Georg Ringer +2
    • Markus Klein +1
    • Anja Leichsenring +1
    • Tymoteusz Motylewski +1
    • Fabien Udriot +1
  • Verified V +2
    • Georg Ringer +2
    • Anja Leichsenring +1
    • Tymoteusz Motylewski +1

Issues 2

Files 2

Review log 22

  1. Mr. Jenkins commented on patch set 1 05/07/14, 17:46

  2. Helmut Hummel uploaded patch set 2 05/07/14, 17:55

  3. Mr. Jenkins commented on patch set 2 05/07/14, 18:15

  4. Philipp Gampe commented on patch set 2 CR +1 05/07/14, 19:59

    Misses Releases: line. IMHO this should still go to 6.2 as an important API enhancement (and is trivial enough to assume no problems). Only if somebody counts on having the array access return NULL, this could lead to a problem. I cannot imagine this.
  5. Markus Klein commented on patch set 2 CR -1 05/07/14, 20:09

    ObjectAccess.php:130

    SplObjectStorage does not implement toArray(), you can access the index directly. As ObjectStorage implements \ArrayAccess as well, I think the toArray() is superfluous in general.
  6. Helmut Hummel commented on patch set 2 05/07/14, 22:16

    ObjectAccess.php:130 Reply

    "SplObjectStorage does not implement toArray()" good point! "As ObjectStorage implements \ArrayAccess as well, I think the toArray() is superfluous in general" nope! see: http://forge.typo3.org/issues/37000
  7. Helmut Hummel commented on patch set 2 05/07/14, 22:22

    ObjectAccess.php:130 Reply

    you can check with return $subject[(int)$propertyName] or return $subject[$propertyName] and you will see the test fail...
  8. Helmut Hummel uploaded patch set 3 05/07/14, 22:23

  9. Helmut Hummel commented on patch set 3 05/07/14, 22:24

    back to my initial solution...
  10. Mr. Jenkins commented on patch set 3 05/07/14, 22:45

  11. Markus Klein updated the commit message in patch set 3 05/07/14, 23:09

  12. Markus Klein commented on patch set 2 05/07/14, 23:14

    ObjectAccess.php:130 Reply

    just a note: it does not matter if you cast the index to int or not. PHP always tries to convert an index to integer internally. so for an array with indexes 0..3 you can use $arr['3'] and it will access 3.
  13. Mr. Jenkins commented on patch set 4 05/07/14, 23:23

  14. Markus Klein uploaded patch set 5 05/08/14, 00:14

  15. Markus Klein commented on patch set 5 CR +1 05/08/14, 00:19

    Verified only with tests.
  16. Mr. Jenkins commented on patch set 5 05/08/14, 00:46

  17. Anja Leichsenring voted on patch set 5 V +1 CR +1 06/01/14, 08:10

  18. Fabien Udriot voted on patch set 5 CR +1 06/01/14, 12:08

  19. Tymoteusz Motylewski commented on patch set 5 V +1 CR +1 06/01/14, 14:07

    tested with modified template of ext:news, works fine
  20. Georg Ringer voted on patch set 5 V +2 CR +2 06/02/14, 10:41

  21. Georg Ringer merged patch set 6 06/02/14, 10:41

  22. Helmut Hummel commented on patch set 6 06/02/14, 16:29

    Thanks everyone!