Review main Merged

29343[BUGFIX] Properly check existence of array item

Markus Klein CR +2 V +2 Easy +15 −10 updated 05/06/14, 10:16

Commit message

The flexform converter in ContentObjectRenderer tries to access
an array element on a non-array.

Check existence with isset() first.

Review

  • Code review CR +2
    • Markus Klein +2
    • Stefan Neufeind +1
    • Julian Wundrak +1
    • Oliver Klee +1
    • Wouter Wolters +1
    • Stefan Froemken +1
  • Verified V +2
    • Markus Klein +2
    • Julian Wundrak +1
    • Stefan Froemken +1
    • Jost Baron +1

Issues 1

Files 1

Review log 33

Show 8 earlier messages
  1. Oliver Klee commented on patch set 1 04/10/14, 16:07

    ContentObjectRenderer.php:1164

    The type "string" here then is wrong, I guess.

    ContentObjectRenderer.php:1184

    Maybe move this part into the guard clause with the continue above?
  2. Mr. Jenkins commented on patch set 1 04/10/14, 16:17

  3. Stefan Neufeind commented on patch set 1 04/10/14, 16:26

    ContentObjectRenderer.php:1164 Reply

    Flexform-data comes as XML inside a string. Not right?

    ContentObjectRenderer.php:1184 Reply

    How? This isset-check can only proceed *if* it is an array.
  4. Stefan Neufeind commented on patch set 1 04/10/14, 16:30

    ContentObjectRenderer.php:1164 Reply

    Okay, got it now - by looking at more than just the short excerpt :-) So it would be string|array
  5. Oliver Klee commented on patch set 1 04/12/14, 07:42

    ContentObjectRenderer.php:1184 Reply

    I was thinking along the line of this: if (!is_array || !isset()) {continue} However, I missed the other if isset($value[vDef]) below. So we cannot consolidate both ifs here.
  6. Markus Klein uploaded patch set 2 04/12/14, 09:11

  7. Mr. Jenkins commented on patch set 2 04/12/14, 09:24

  8. Oliver Klee voted on patch set 2 CR +1 04/12/14, 10:47

  1. Christian Kuhn commented on patch set 2 04/12/14, 10:54

    ContentObjectRenderer.php:1177

    can't this is_array check be moved above the isset() check?
  2. Oliver Klee commented on patch set 2 CR -1 04/12/14, 10:59

    ContentObjectRenderer.php:1177 Reply

    That's what I though as well. However, $flexData might be overwritten in lines 1175. I think we should have different variables for this instead of just overwriting the same variable again and again. (That's a smell from the Refactoring book IIRC.)
  3. Christian Kuhn commented on patch set 2 CR -1 04/12/14, 13:13

    -1, I'll refactor this a bit now.
  4. Christian Kuhn uploaded patch set 3 04/12/14, 13:36

  5. Christian Kuhn voted on patch set 3 CR -1 04/12/14, 13:37

  6. Christian Kuhn uploaded patch set 4 04/12/14, 13:38

  7. Christian Kuhn commented on patch set 4 CR -1 04/12/14, 13:39

    Just moved the early return more up but stayed with the variable name (trying to change that does not lead to much better readable code in this case). Anyway, this patch would be a good opportunity to add a basic test coverage for this method, so -1 from me until this is done.
  8. Mr. Jenkins commented on patch set 3 04/12/14, 13:50

  9. Mr. Jenkins commented on patch set 4 04/12/14, 13:51

  10. Oliver Klee commented on patch set 4 04/12/14, 14:27

    ContentObjectRenderer.php:1179

    Couldn't we then run into a case where $flexData is not an array anymore at this point?
  11. Markus Klein commented on patch set 4 CR -1 04/12/14, 14:31

    ContentObjectRenderer.php:1179 Reply

    That's why I moved the isset() check up, to ensure that we have an array before the foreach loop
  12. Markus Klein uploaded patch set 5 04/12/14, 14:33

  13. Mr. Jenkins commented on patch set 5 04/12/14, 14:47

  14. Oliver Klee voted on patch set 5 CR +1 04/12/14, 17:08

  15. Christian Kuhn commented on patch set 5 04/12/14, 17:11

    still it would be great to have test coverage for this method, afaik anja is working on that already.
  16. Stefan Neufeind commented on patch set 5 04/12/14, 19:11

    @Anja: Are you active in this area? Results soon maybe or a partial result (of a larger changeset) that you could contribute to this patchset here?
  17. Anja Leichsenring commented on patch set 5 04/13/14, 11:42

    I try to come up with some tests, but currently can't get the input working. So if someone can show me some possible values, that might be passed to this method, I would be grateful. In every case I can not deliver today.
  18. Jost Baron voted on patch set 5 V +1 04/24/14, 23:13

  19. Wouter Wolters voted on patch set 5 CR +1 04/29/14, 18:36

  20. Julian Wundrak voted on patch set 5 V +1 CR +1 04/29/14, 18:40

  21. Stefan Neufeind commented on patch set 5 CR +1 04/29/14, 22:01

    @Anja: Do you expect it's realistic to wait for a testcase? Or do you think you won't make it "soon"?
  22. Stefan Froemken commented on patch set 5 V +1 CR +1 04/30/14, 08:35

    ContentObjectRenderer.php:1184

    What do think about the count here? Can we remove it? WW told me in one of my patches that "count" is expensive.
  23. Oliver Klee commented on patch set 5 04/30/14, 10:38

    ContentObjectRenderer.php:1184 Reply

    Yes, for arrays, empty() instead of count() > 0 would be faster. I wouldn't vote a -1 for this here, though, so we can get this change in quickly.
  24. Markus Klein commented on patch set 5 V +2 CR +2 05/06/14, 10:16

    This has enough votes for a long time now.
  25. Markus Klein merged patch set 6 05/06/14, 10:16