Review main Merged

63720[BUGFIX] Avoid validation failure on multi select fields without option

Marco Huber CR +2 V +2 Easy +27 −3 updated 03/21/20, 11:58

Commit message

Multi Select fields without any option given will be added properly to
the forms __trustedProperties list and therefor no longer cause
validation errors.

Review

  • Code review CR +2 Done
    • Anja Leichsenring +2
    • Marco Huber +1
  • Verified V +2 Done
    • Anja Leichsenring +2
    • Marco Huber +1
    • TYPO3com +1 CI

Issues 1

Files 2

Review log 2231

Show 26 earlier messages
  1. Marco Huber uploaded patch set 1 03/14/20, 14:01

  2. TYPO3com voted on patch set 1 V -1 03/14/20, 14:12 Completed build in 11m 17s on Sat, 14 Mar, 02:12 PM Test Summary: 72201 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1343

  3. TYPO3com voted on patch set 1 V +1 03/14/20, 14:56 Completed build in 1h 06m 11s on Sat, 14 Mar, 02:56 PM Test Summary: 72201 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1343

  4. TYPO3com voted on patch set 1 V -1 03/14/20, 15:30 Completed build in 12m 00s on Sat, 14 Mar, 03:30 PM Test Summary: 72192 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1345

  5. TYPO3com voted on patch set 1 V +1 03/15/20, 09:45 Completed build in 20m 16s on Sun, 15 Mar, 09:45 AM Test Summary: 72267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1359

  6. Susi Moog commented on patch set 1 03/15/20, 10:59

    SelectViewHelper.php:153 Unresolved

    use do {...} while() instead?
  1. Marco Huber uploaded patch set 2 03/15/20, 12:44

  2. Marco Huber commented on patch set 2 03/15/20, 12:47

    Susi, I hope this is what you meant. If not, I need a hint :-)
  3. TYPO3com voted on patch set 2 V -1 03/15/20, 12:55 Completed build in 11m 07s on Sun, 15 Mar, 12:55 PM Test Summary: 72270 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1361

  4. Claus Due commented on patch set 2 03/15/20, 13:46

    SelectViewHelper.php:149

    Moving the registerFieldNameForFormTokenGeneration call outside of this condition and removing the entire loop below should have the same function (and would increase performance). In https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/extbase/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php#L102 the built field names array should only contain one entry per field name, so repeatedly registering the same field name should make no difference. But please confirm. I'm on mobile and unable to test.
  5. Claus Due commented on patch set 2 03/15/20, 13:47

    SelectViewHelper.php:166 Unresolved

    ...if the above is true then this else-case can of course also be removed.
  6. Claus Due rebased onto patch set 3 03/15/20, 13:49

  7. Claus Due commented on patch set 3 03/15/20, 13:50

    Rebasing to hopefully get rid of unrelated CI failure.
  8. TYPO3com voted on patch set 3 V -1 03/15/20, 14:06 Completed build in 14m 16s on Sun, 15 Mar, 02:06 PM Test Summary: 72270 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1365

  9. Marco Huber commented on patch set 3 03/15/20, 23:36

    > Patch Set 2: > > (1 comment) Sorry Claus, I don't get exactly what you mean. There are so many "register something" functions and I don't really understand what they do and when a field has to be registered somewhere :-). But if you create a new patch I would be happy to test it.
  10. Susi Moog commented on patch set 3 03/16/20, 05:07

    > Patch Set 2: > > Susi, I hope this is what you meant. If not, I need a hint :-) ah, nearly :) What I meant was that we could also get rid of the if / else part with the do while thing. The if else is there to only do it once if there are no options and as many times as there are options in all the other cases - so removing the if / else and using the do - while should have the same effect.

    SelectViewHelper.php:149 Reply

    just from reading the code: the comment says otherwise and the code actually reacts differently on the same field name when registering it multiple times.
  11. Claus Due commented on patch set 3 03/16/20, 09:32

    SelectViewHelper.php:149 Reply Unresolved

    I have now checked with a practical test, and yes the checksum and trusted fields string is different if registering the same field name multiple times. We can however make this a bit less complex: // register field name for token generation. // in case it is a multi-select, we need to register the field name // as often as there are elements in the box $this->registerFieldNameForFormTokenGeneration($name); if (isset($this->arguments['multiple']) && $this->arguments['multiple']) { $content .= $this->renderHiddenFieldForEmptyValue(); $optionsCount = count($options); for ($i = 1; $i < $optionsCount; $i++) { // Register the field name additional times as required by the total number of // options. Since we already registered it once above, we start the counter at 1 // instead of 0. $this->registerFieldNameForFormTokenGeneration($name); } // save the parent field name so that any child f:form.select.option // tag will know to call registerFieldNameForFormTokenGeneration // this is the reason why "self::class" is used instead of static::class (no LSB) $viewHelperVariableContainer->addOrUpdate( self::class, 'registerFieldNameForFormTokenGeneration', $name ); } In short: register the field name once, regardless of "multiple" attribute. If "multiple" is true we then call the "register" method as many additional times as is required by the number of options in the field. We avoid the "else" case and don't have to modify the loop itself, only the number of times it loops.
  12. Marco Huber uploaded patch set 4 03/16/20, 09:57

  13. Claus Due voted on patch set 4 CR +1 03/16/20, 10:03

  14. Marco Huber commented on patch set 4 03/16/20, 10:03

    I was confused how we can remove the complete if/else, because that would have changed to much :-)
  15. TYPO3com voted on patch set 4 V +1 03/16/20, 10:12 Completed build in 15m 04s on Mon, 16 Mar, 10:12 AM Test Summary: 72270 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1376

  16. Susi Moog voted on patch set 4 CR +1 03/19/20, 12:25

  17. Susi Moog voted on patch set 4 V +1 03/21/20, 09:07

  18. Anja Leichsenring updated the commit message in patch set 5 03/21/20, 09:39

  19. Anja Leichsenring uploaded patch set 6 03/21/20, 09:57

  20. Anja Leichsenring voted on patch set 6 V +1 CR +1 03/21/20, 10:25

  21. TYPO3com voted on patch set 5 V +1 03/21/20, 10:35 Completed build in 45m 30s on Sat, 21 Mar, 10:35 AM Test Summary: 72225 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1533

  22. TYPO3com voted on patch set 6 V +1 03/21/20, 10:44 Completed build in 19m 17s on Sat, 21 Mar, 10:44 AM Test Summary: 72231 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1534

  23. Marco Huber voted on patch set 6 V +1 CR +1 03/21/20, 11:36

  24. Anja Leichsenring voted on patch set 6 V +2 CR +2 03/21/20, 11:58

  25. Anja Leichsenring merged patch set 7 03/21/20, 11:58