Review main Merged

55820[BUGFIX] Let form framework finisher parseOption respect arrays

Ralf Zimmermann CR +2 V +2 Hard +464 −272 updated 04/18/18, 12:21

Commit message

The method "parseOption()" can now handle arrays. This is necessary if a
finisher option references a form element value through an
identifier like "someOption: '{<elemenIdentifier>}'" and if
the form element value is an array (e.g. MultiCheckbox).
Furthermore "parseOption()" resolves form element references
within localized option values.

Review

  • Code review CR +2
    • Frank Nägler +2
    • Stefan Froemken +1
  • Verified V +2
    • Frank Nägler +2
    • Stefan Froemken +1
    • TYPO3com +1 CI

Issues 2

Files 2

Review log 4872

Show 3047 earlier messages
  1. Ralf Zimmermann uploaded patch set 1 02/20/18, 09:19

  2. Ralf Zimmermann uploaded patch set 2 02/20/18, 09:23

  3. TYPO3com voted on patch set 1 V +1 02/20/18, 09:28 Completed build in 08m 07s on Tue, 20 Feb, 10:28 AM Test Summary: 30902 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19889

  4. TYPO3com voted on patch set 2 V +1 02/20/18, 09:32 Completed build in 08m 51s on Tue, 20 Feb, 10:32 AM Test Summary: 30902 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19890

  5. Björn Jacob updated the commit message in patch set 3 02/20/18, 17:22

  6. TYPO3com voted on patch set 3 V +1 02/20/18, 17:36 Completed build in 14m 06s on Tue, 20 Feb, 06:36 PM Test Summary: 30902 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19933

  7. Oliver Hader updated the commit message in patch set 4 02/20/18, 18:06

  8. TYPO3com voted on patch set 4 V +1 02/20/18, 18:17 Completed build in 10m 49s on Tue, 20 Feb, 07:17 PM Test Summary: 30902 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19938

  9. Oliver Hader commented on patch set 4 CR -1 02/21/18, 10:26

    Given the following: * options property is an array, e.g. [ '{multicheckbox-1}', 'some static value' ] * multicheckbox-1 has two selected options [ 'aa', 'bb' ] Then the preg_replace_callback invocation would result in: * [ 'aa', 'bb'] since it replaces $optionValue by reference on the first option item '{multicheckbox-1}' However, I guess that the expected output then should be: [ ['aa','bb'], 'some static value' ] Besides that, adjusting $optionValue by reference feels hacky and should be avoided.

    AbstractFinisher.php:210

    Now this overrides all options and I'm not sure whether this is the expected behavior, since the callback is executed for each item in case $optionValue is an array.
  10. Oliver Hader commented on patch set 4 02/21/18, 10:27

  11. Oliver Hader commented on patch set 4 02/21/18, 10:30

    AbstractFinisher.php:210 Reply

    I think, it still should `return $value;` here as well - using &$optionValue could be omitted then
  12. Ralf Zimmermann commented on patch set 4 02/21/18, 10:36

    AbstractFinisher.php:210 Reply

    if preg_replace_callback got $optionValue = '{some-identifier}', and the formRuntime value for '{some-identifier}' is an array, than preg_replace_callback returns "Array" as a string if i use the "return $value" statement. preg_replace_callback returns an array if the input is an array. preg_replace_callback can't handle the case, if the input is a string and the output is an array. This is why i use the reference value.
  13. Ralf Zimmermann commented on patch set 4 CR -1 02/21/18, 11:00

    on it
  14. Ralf Zimmermann uploaded patch set 5 02/21/18, 12:19

  15. TYPO3com voted on patch set 5 V -1 02/21/18, 12:19 Completed build in 10s on Wed, 21 Feb, 01:19 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19970

  16. Ralf Zimmermann uploaded patch set 6 02/21/18, 12:21

  17. TYPO3com voted on patch set 6 V -1 02/21/18, 12:28 Completed build in 07m 28s on Wed, 21 Feb, 01:28 PM Test Summary: 2 of 31063 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19971

  18. TYPO3com voted on patch set 6 V +1 02/21/18, 13:29 Completed build in 1h 15m 39s on Wed, 21 Feb, 02:29 PM Test Summary: 30911 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19971

  19. Ralf Zimmermann commented on patch set 7 02/21/18, 13:33

    Published edit on patch set 6.
  20. TYPO3com voted on patch set 7 V +1 02/21/18, 13:42 Completed build in 08m 38s on Wed, 21 Feb, 02:42 PM Test Summary: 30911 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19972

  21. Oliver Hader uploaded patch set 8 02/21/18, 15:25

  22. TYPO3com voted on patch set 8 V -1 02/21/18, 15:26 Completed build in 09s on Wed, 21 Feb, 04:26 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19981

  23. Oliver Hader commented on patch set 7 02/21/18, 15:26

    AbstractFinisher.php:192

    Shouldn't this be $optionName . $key?
  24. Oliver Hader commented on patch set 7 02/21/18, 15:28

    I've refactored the code a bit and allowed to recursively resolve translations for the resolved values (either from form runtime data or the initial finisher options in case any of those had a nested structure).
  25. Oliver Hader uploaded patch set 9 02/21/18, 15:28

  26. Oliver Hader commented on patch set 9 02/21/18, 15:33

    AbstractFinisher.php:306

    There's one thing that just came to my mind: In case $needle is a string having "{field-1},{field-2}" - this now would override the return value with the last match being processed, thus only the resolved value for "{field-2}"
  27. TYPO3com voted on patch set 9 V +1 02/21/18, 15:36 Completed build in 08m 01s on Wed, 21 Feb, 04:36 PM Test Summary: 30911 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19982

  28. Ralf Zimmermann commented on patch set 9 02/21/18, 17:35

    on it
  29. Ralf Zimmermann uploaded patch set 10 02/21/18, 17:42

  30. TYPO3com voted on patch set 10 V -1 02/21/18, 17:42 Completed build in 09s on Wed, 21 Feb, 06:42 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19987

  31. Ralf Zimmermann commented on patch set 10 02/21/18, 17:51

    AbstractFinisher.php:192 Reply

    No. This variable is used to build the translation key. If $optionName = 'someOptionName' and $value = 'someOptionValue', the translation service will look for a tranlation key like "some-form-identifier.finisher.Foo.someOptionName.someOptionValue".
  32. Ralf Zimmermann uploaded patch set 11 02/21/18, 17:52

  33. TYPO3com voted on patch set 11 V +1 02/21/18, 18:00 Completed build in 07m 50s on Wed, 21 Feb, 07:00 PM Test Summary: 30914 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19990

  34. Oliver Hader uploaded patch set 12 02/21/18, 19:19

  35. Oliver Hader commented on patch set 12 02/21/18, 19:23

    AbstractFinisher.php:227

    @Ralf: I've changed that back to use $value (instead of $key) as you explained

    AbstractFinisher.php:279

    That's the only part where array from FormRuntime are returned - in case only the variable is used

    AbstractFinisher.php:301

    This triggers the regular replacement on each finding - as it has been prior to this patch for regular plain string values

    AbstractFinisher.php:309

    For having an option like "BEFORE,{multicheckbox-1},AFTER" it cannot be substituted - that's why an exception is thrown now. That's catching the case of having "BEFORE,Array,AFTER" when converted from array to string
  36. Oliver Hader uploaded patch set 13 02/21/18, 19:25

  37. TYPO3com voted on patch set 12 V +1 02/21/18, 19:27 Completed build in 07m 40s on Wed, 21 Feb, 08:27 PM Test Summary: 30917 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19995

  38. TYPO3com voted on patch set 13 V +1 02/21/18, 19:34 Completed build in 08m 41s on Wed, 21 Feb, 08:34 PM Test Summary: 30917 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19996

  39. Oliver Hader voted on patch set 13 V +1 CR +1 02/22/18, 20:56

  40. Ralf Zimmermann voted on patch set 13 V +1 CR +1 02/22/18, 20:57

  41. Ralf Zimmermann uploaded patch set 14 02/23/18, 09:07

  42. TYPO3com voted on patch set 14 V +1 02/23/18, 09:15 Completed build in 08m 26s on Fri, 23 Feb, 10:15 AM Test Summary: 30896 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20051

  43. Ralf Zimmermann uploaded patch set 15 03/15/18, 21:13

  44. TYPO3com voted on patch set 15 V +1 03/15/18, 21:24 Completed build in 10m 44s on Thu, 15 Mar, 10:24 PM Test Summary: 30894 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-21155

  45. Ralf Zimmermann uploaded patch set 16 03/18/18, 01:00

  46. TYPO3com voted on patch set 16 V -1 03/18/18, 01:09 Completed build in 08m 56s on Sun, 18 Mar, 02:09 AM Test Summary: 3 of 31049 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-21589

  47. Ralf Zimmermann uploaded patch set 17 03/18/18, 01:15

  1. TYPO3com voted on patch set 17 V +1 03/18/18, 01:24 Completed build in 09m 09s on Sun, 18 Mar, 02:24 AM Test Summary: 30897 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-21591

  2. Stefan Froemken commented on patch set 17 V -1 04/17/18, 10:57

    I get following error with my FlashMessageFinisher and severity = 1: Oops, an error occurred! Argument 4 passed to TYPO3\CMS\Form\Service\TranslationService::translateFinisherOption() must be of the type string, integer given, called in /Users/stefan/htdocs/typo3_src/typo3/sysext/form/Classes/Domain/Finishers/AbstractFinisher.php on line 244
  3. Ralf Zimmermann commented on patch set 17 04/17/18, 13:06

    on it
  4. Ralf Zimmermann uploaded patch set 18 04/17/18, 13:23

  5. TYPO3com voted on patch set 18 V +1 04/17/18, 13:34 Completed build in 10m 01s on Tue, 17 Apr, 03:34 PM Test Summary: 30965 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22469

  6. Stefan Froemken commented on patch set 18 V -1 04/17/18, 13:35

    Hi Ralf. Please do not convert INT values to STRING. 1 is not "1" and this will break FlashMessageFinishers: Oops, an error occurred! Argument 1 passed to TYPO3\CMS\Core\Messaging\AbstractMessage::setSeverity() must be of the type integer, string given, called in /Users/stefan/htdocs/typo3_src/typo3/sysext/core/Classes/Messaging/FlashMessage.php on line 42
  7. Oliver Hader commented on patch set 18 04/17/18, 14:22

    @StefanFroemken: Can you please add a stack-trace of the misbehavior you're referring to? Thanks in advance
  8. Stefan Froemken commented on patch set 18 04/17/18, 15:41

    https://forge.typo3.org/issues/84698 Yaml-Parser interpretes severity as int correctly. In AbstractFinisher you convert optionValue to string while calling translateFinisherOption(). I don't know why you want to translate an int value?!?! That's why I prefer to early return int values before calling the translation thing. translateFinisherOption will return string or array types only. So, at that point our severity is of type string now. The switch-case in FlashMessageFinisher works, too. But than you create a new object of type FlashMessage. Within its contructor you are calling setSeverity() which is defined as: setSeverity(int $severity = self::OK). Do you see the problem. $severity has to be of type int
  9. Ralf Zimmermann uploaded patch set 19 04/17/18, 20:27

  10. Ralf Zimmermann voted on patch set 19 CR -1 04/17/18, 20:28

  11. Ralf Zimmermann uploaded patch set 20 04/17/18, 20:28

  12. TYPO3com voted on patch set 19 V +1 04/17/18, 20:36 Completed build in 09m 19s on Tue, 17 Apr, 10:36 PM Test Summary: 31001 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22501

  13. TYPO3com voted on patch set 20 V +1 04/17/18, 20:39 Completed build in 10m 45s on Tue, 17 Apr, 10:39 PM Test Summary: 31001 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22502

  14. Mathias Schreiber voted on patch set 20 V +1 CR +1 04/17/18, 21:27

  15. Kay Strobach commented on patch set 20 CR +1 04/17/18, 21:34

    looks good imho
  16. Stefan Froemken commented on patch set 20 CR -1 04/18/18, 05:52

    AbstractFinisher.php:186

    Either isset or ?? but not both
  17. Ralf Zimmermann commented on patch set 20 04/18/18, 07:14

    > Patch Set 20: Code-Review-1 > > (1 comment) This prevents "Undefined index: translation" PHP notices.
  18. Ralf Zimmermann rebased onto patch set 21 04/18/18, 07:18

  19. TYPO3com voted on patch set 21 V -1 04/18/18, 07:19 Completed build in 46s on Wed, 18 Apr, 09:19 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22517

  20. Ralf Zimmermann uploaded patch set 22 04/18/18, 07:20

  21. TYPO3com voted on patch set 22 V -1 04/18/18, 07:34 Completed build in 14m 08s on Wed, 18 Apr, 09:34 AM Test Summary: 2 of 30871 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22518

  22. TYPO3com voted on patch set 22 V +1 04/18/18, 09:06 Completed build in 2h 00m 30s on Wed, 18 Apr, 11:06 AM Test Summary: 31001 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-22518

  23. Stefan Froemken voted on patch set 22 V +1 CR +1 04/18/18, 10:31

  24. Frank Nägler voted on patch set 22 V +2 CR +2 04/18/18, 12:21

  25. Frank Nägler merged patch set 23 04/18/18, 12:21