Review main Merged

61696[BUGFIX] Add support for options in "Execute console commands"

Matthias Vogel CR +2 V +2 Normal +199 −10 updated 01/16/20, 12:55

Commit message

Review

  • Code review CR +2 Done
    • Daniel Goerz +2
    • Sascha Rademacher +1
    • Felix P. +1
    • Susi Moog +1
  • Verified V +2 Done
    • Daniel Goerz +2
    • Sascha Rademacher +1
    • Felix P. +1
    • Susi Moog +1
    • TYPO3com +1 CI

Issues 1

Files 3

Review log 5068

Show 3143 earlier messages
  1. Matthias Vogel uploaded patch set 1 09/12/19, 11:26

  2. TYPO3com voted on patch set 1 V -1 09/12/19, 11:26 Completed build in 07s on Thu, 12 Sep, 11:26 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36355

  3. Matthias Vogel uploaded patch set 2 09/12/19, 11:29

  4. TYPO3com voted on patch set 2 V +1 09/12/19, 11:42 Completed build in 12m 12s on Thu, 12 Sep, 11:42 AM Test Summary: 47536 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36356

  5. Matthias Vogel uploaded patch set 3 10/08/19, 15:02

  6. TYPO3com voted on patch set 3 V -1 10/08/19, 15:14 Completed build in 11m 06s on Tue, 8 Oct, 03:13 PM Test Summary: 47719 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-37150

  7. TYPO3com voted on patch set 3 V +1 10/08/19, 15:15 Completed build in 23m 12s on Tue, 8 Oct, 03:14 PM Test Summary: 47719 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-37150

  8. Jörg Bösche commented on patch set 3 CR -1 10/09/19, 09:22

    ExecuteSchedulableCommandAdditionalFieldProvider.php:377 Unresolved

    $inputTag = new TagBuilder(); should be moved outside of the condition to reduce redundant code lines and have a default $inputTag assignment. Also move setTageName('input') outside of the condition.
  9. Christian Benthake commented on patch set 3 10/09/19, 13:22

    ExecuteSchedulableCommandTask.php:176 Unresolved

    maybe thats a little more readable if ($forDisplay && $value === true) { $value = ''; } $options['--' . $name] = $value;
  10. Matthias Vogel uploaded patch set 4 10/10/19, 11:22

  11. TYPO3com voted on patch set 4 V +1 10/10/19, 11:32 Completed build in 10m 30s on Thu, 10 Oct, 11:32 AM Test Summary: 47719 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-37207

  12. Christian Benthake voted on patch set 4 CR +1 10/10/19, 12:00

  13. Frank Nägler voted on patch set 4 CR +1 10/18/19, 14:05

  14. Tomas Norre Mikkelsen voted on patch set 4 V +1 CR +1 12/03/19, 08:45

  15. Susi Moog commented on patch set 4 V -1 12/06/19, 08:58

    While the option field gets rendered correctly, it does not store the value after saving the task.
  16. Sebastian Mazza commented on patch set 4 V -1 12/06/19, 11:57

    > Patch Set 4: Verified-1 > > While the option field gets rendered correctly, it does not store the value after saving the task. I can confirm this, the entered option values can not be saved.
  17. Sebastian Mazza uploaded patch set 5 12/06/19, 14:58

  18. TYPO3com voted on patch set 5 V -1 12/06/19, 14:59 Completed build in 15s on Fri, 6 Dec, 02:59 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39173

  19. Sebastian Mazza uploaded patch set 6 12/06/19, 15:05

  20. TYPO3com voted on patch set 6 V +1 12/06/19, 15:12 Completed build in 06m 55s on Fri, 6 Dec, 03:12 PM Test Summary: 68730 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39174

  21. Sebastian Mazza commented on patch set 6 12/06/19, 15:16

    I fixed the problem with the option values that can not be saved. Furthermore, I added a validation for required options.
  22. Susi Moog voted on patch set 6 V +1 CR +1 12/06/19, 15:56

  23. Tomas Norre Mikkelsen voted on patch set 6 CR +1 12/07/19, 09:49

  24. Daniel Goerz commented on patch set 6 V -1 12/07/19, 17:33

    I can not leave an option input field empty as they are all mandatory. Also I cannot set 0 as a value. IDK if that's intended? Otherwise, patch looks good.
  25. Susi Moog commented on patch set 6 12/08/19, 07:01

    > Patch Set 6: Verified-1 > > I can not leave an option input field empty as they are all mandatory. Also I cannot set 0 as a value. IDK if that's intended? Otherwise, patch looks good. Hmm, how did you test? Can you add your scenario? I tested: - InputOption::VALUE_NONE: renders checkbox, can be saved enabled or disabled - InputOption::VALUE_REQUIRED: renders input field, cannot be saved without any input, can be saved with input like "foo", 123 or 0 - InputOption::VALUE_OPTIONAL: renders input field, can be saved empty, can be saved with strings or numbers - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY: renders input field as required, transforms comma-separated list to array as options
  26. Sebastian Mazza uploaded patch set 7 12/08/19, 14:48

  27. TYPO3com voted on patch set 7 V +1 12/08/19, 14:57 Completed build in 09m 16s on Sun, 8 Dec, 02:57 PM Test Summary: 68708 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39269

  28. Sebastian Mazza commented on patch set 7 12/08/19, 15:07

    > Patch Set 6: Verified-1 > > I can not leave an option input field empty as they are all mandatory. Also I cannot set 0 as a value. IDK if that's intended? Otherwise, patch looks good. I was not able to reproduce "can not leave an option input field empty" it the filed has the mode VALUE_OPTIONAL. If the field has the mode VALUE_REQUIRED, it is not possible to store an empty string, but this is intended. The string "0" can be stored even for options with mode VALUE_REQUIRED. However, the string "0" was not showen in the option list of the scheduler list view and, also, not provided to the Command->execute $input. I fixed that in patch set 7. --------------- my test options: $this->addOption( 'test-bool', '', InputOption::VALUE_NONE, 'Test Flag', null ); $this->addOption( 'test-option-without-default', '', InputOption::VALUE_OPTIONAL, 'Test optional without default', null ); $this->addOption( 'test-option-with-default', '', InputOption::VALUE_OPTIONAL, 'Test optional with default', 123 ); $this->addOption( 'test-required-without-default', '', InputOption::VALUE_REQUIRED, 'Test required without default', null ); $this->addOption( 'test-required-with-default', '', InputOption::VALUE_REQUIRED, 'Test required with default', 321 ); $this->addOption( 'test-array-option-without-default', '', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Test array optional without default', null ); $this->addOption( 'test-array-option-with-default', '', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Test array optional with default', [1,2,3] ); $this->addOption( 'test-array-required-without-default', '', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Test array required without default', null ); $this->addOption( 'test-array-required-with-default', '', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Test array required with default', [1,2,3] ); -------------- and my probably hardest test values: test-bool:[unchecked] test-option-without-default:"" test-option-with-default:"" test-required-without-default:"0" test-required-with-default:"0" test-array-option-without-default:"" test-array-option-with-default:"" test-array-required-without-default:"0" test-array-required-with-default:"0"
  29. Daniel Goerz commented on patch set 7 12/08/19, 16:45

    > Patch Set 6: > > > Patch Set 6: Verified-1 > > > > I can not leave an option input field empty as they are all mandatory. Also I cannot set 0 as a value. IDK if that's intended? Otherwise, patch looks good. > > Hmm, how did you test? Can you add your scenario? > > I tested: > - InputOption::VALUE_NONE: renders checkbox, can be saved enabled or disabled > - InputOption::VALUE_REQUIRED: renders input field, cannot be saved without any input, can be saved with input like "foo", 123 or 0 > - InputOption::VALUE_OPTIONAL: renders input field, can be saved empty, can be saved with strings or numbers > - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY: renders input field as required, transforms comma-separated list to array as options I tested an example with on InputOption::VALUE_REQUIRED options. Those are all required when creating the scheduler task. But that is not what InputOption::VALUE_REQUIRED means IIRC, because it just states, that the option needs a value if it is set. But the option itself is still optional, as all options in symfony commands are. So those fields should not be required. If they are left empty the option must not be added to the command. IDK how to solve this for InputOption::VALUE_OPTIONAL tbh. I hope I am not wrong here (absolutely possible) :) Regarding the "0" value thing, I did not phrase that very well. The form could be submitted but the option was not added to the command. But this is fixed with PS7 if I see it correctly, so we're good here.
  30. Sebastian Mazza commented on patch set 7 12/08/19, 17:57

    > Patch Set 7: > > > Patch Set 6: > > > > > Patch Set 6: Verified-1 > > > > > > I can not leave an option input field empty as they are all mandatory. Also I cannot set 0 as a value. IDK if that's intended? Otherwise, patch looks good. > > > > Hmm, how did you test? Can you add your scenario? > > > > I tested: > > - InputOption::VALUE_NONE: renders checkbox, can be saved enabled or disabled > > - InputOption::VALUE_REQUIRED: renders input field, cannot be saved without any input, can be saved with input like "foo", 123 or 0 > > - InputOption::VALUE_OPTIONAL: renders input field, can be saved empty, can be saved with strings or numbers > > - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY: renders input field as required, transforms comma-separated list to array as options > > I tested an example with on InputOption::VALUE_REQUIRED options. Those are all required when creating the scheduler task. But that is not what InputOption::VALUE_REQUIRED means IIRC, because it just states, that the option needs a value if it is set. But the option itself is still optional, as all options in symfony commands are. > > So those fields should not be required. If they are left empty the option must not be added to the command. IDK how to solve this for InputOption::VALUE_OPTIONAL tbh. > > I hope I am not wrong here (absolutely possible) :) > > Regarding the "0" value thing, I did not phrase that very well. The form could be submitted but the option was not added to the command. But this is fixed with PS7 if I see it correctly, so we're good here. I understand your point now and I think you are right. "Options are always optional" [https://symfony.com/doc/current/console/input.html#using-command-options] The only solution I can imagine at the moment is to make a checkbox for every option and a text input for all modes except InputOption::VALUE_NONE.
  31. Sebastian Mazza uploaded patch set 8 12/08/19, 22:24

  32. TYPO3com voted on patch set 8 V -1 12/08/19, 22:25 Completed build in 13s on Sun, 8 Dec, 10:25 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39274

  33. Sebastian Mazza uploaded patch set 9 12/08/19, 22:27

  34. TYPO3com voted on patch set 9 V -1 12/08/19, 22:27 Completed build in 13s on Sun, 8 Dec, 10:27 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39275

  35. Sebastian Mazza uploaded patch set 10 12/08/19, 22:34

  36. TYPO3com voted on patch set 10 V +1 12/08/19, 22:41 Completed build in 07m 21s on Sun, 8 Dec, 10:41 PM Test Summary: 68706 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39276

  37. Susi Moog commented on patch set 10 12/09/19, 05:33

    > Patch Set 7: > > So those fields should not be required. If they are left empty the option must not be added to the command. IDK how to solve this for InputOption::VALUE_OPTIONAL tbh. > > I hope I am not wrong here (absolutely possible) :) You are never wrong ;) - I didn't get the meaning of those options. Thanks for explaining.
  38. Oli Bartsch commented on patch set 10 CR -1 12/09/19, 06:52

    ExecuteSchedulableCommandAdditionalFieldProvider.php:147 Unresolved

    Is this a common notation for ”empty or NULL“?

    ExecuteSchedulableCommandAdditionalFieldProvider.php:336

    Is hsc not needed for the name?

    ExecuteSchedulableCommandTask.php:195 Unresolved

    Return type missing

    ExecuteSchedulableCommandTask.php:200

    Could we please use isset or ??

    ExecuteSchedulableCommandTask.php:201 Unresolved

    Maybe we could make shorthanded here and put it in line 204.

    locallang.xlf:184 Unresolved

    Add option
  39. Sebastian Mazza commented on patch set 10 12/09/19, 08:39

    > Patch Set 10: Code-Review-1 > > (6 comments)

    ExecuteSchedulableCommandAdditionalFieldProvider.php:336 Reply

    I don't think that an option name should contain any html special chars. Also for the $argument->getName() no hsc is used (line 325). If we add a htmlspecialchars() here, we also should add one for the argument names?

    ExecuteSchedulableCommandTask.php:200 Reply

    I don't want to prevent NULL values, just PHP Warnings. The Symphony command option parser also uses NULL to indicate that an option with mode InputOption::VALUE_OPTIONAL is used without a value.
  40. Alexander Schnitzler commented on patch set 10 12/09/19, 09:28

    ExecuteSchedulableCommandTask.php:200 Reply Unresolved

    > $this->optionValues[$name] ?? null; does not prevent null values. Technically it does if $this->optionValues[$name] === null but it does not change the outcome.
  41. Oli Bartsch commented on patch set 10 12/09/19, 09:50

    ExecuteSchedulableCommandAdditionalFieldProvider.php:336 Reply Unresolved

    Generally I try to always use hsc for string values which should be rendered in HTML in some way by not exactly knowing it's content. Surely the name should not contain special chars but IMO that won't prevent one to anyhow use it. So yes I would also apply it to $argument->getName() but I don't know if we should touch parts not directly related to this patch.
  42. Sebastian Mazza uploaded patch set 11 12/09/19, 20:26

  43. TYPO3com voted on patch set 11 V -1 12/09/19, 20:34 Completed build in 07m 29s on Mon, 9 Dec, 08:34 PM Test Summary: 58618 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39296

  1. Oli Bartsch commented on patch set 11 12/10/19, 06:19

    ExecuteSchedulableCommandAdditionalFieldProvider.php:91

    Seems I overlooked that yesterday. This is in contrast to 'argument' plural. Should we unify this? What do you think makes more sense, make this `$optionFields` and `getCommandOptionFields()` or adjusting the `argumentField` to `argumentsFields` and `getCommandArgumentsFields()`?

    ExecuteSchedulableCommandAdditionalFieldProvider.php:285

    Shouldn’t that be 'options'?
  2. Sebastian Mazza commented on patch set 11 12/10/19, 09:05

    > Patch Set 11: > > (2 comments)

    ExecuteSchedulableCommandAdditionalFieldProvider.php:91 Reply

    I think `$optionFields` and `getCommandOptionFields()` is nicer to read.

    ExecuteSchedulableCommandAdditionalFieldProvider.php:146 Unresolved

    Should we check individual values for option with mode (InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED)? Currently it is possible to enter a value like "foo," for an option "o" with mode (InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED), which is equal to the command line string "--o=foo --o". I think that this is wrong. We could explode the value for "ARRAY" options and validate each array element individually. Otherwise, such a solution could be a bit overengineer and eventually prevents a use case that I do not think of. (I have not much experience with Symphonies command controllers.) Posible replacement: $optionEnabled = $submittedData['task_executeschedulablecommand']['options'][$optionDefinition->getName()] ?? false; $optionValue = $submittedData['task_executeschedulablecommand']['option_values'][$optionDefinition->getName()] ?? $optionDefinition->getDefault(); if ($optionEnabled && $optionDefinition->isValueRequired()) { if ($optionDefinition->isArray()) { if (is_array($optionValue)) { $optionValueList = $optionValue; } else { $optionValueList = GeneralUtility::trimExplode(',', $optionValue, false); } } else { $optionValueList = [$optionValue]; } foreach ($optionValueList as $testValue) { if ($testValue === null || trim($testValue) === '') { // An option that requires a value is used with an empty value $flashMessageService->getMessageQueueByIdentifier()->addMessage( new FlashMessage( sprintf( $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.mandatoryArgumentMissing'), $optionDefinition->getName() ), $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.updateError'), FlashMessage::ERROR ) ); $hasErrors = true; } } }

    ExecuteSchedulableCommandAdditionalFieldProvider.php:285 Reply

    Yes, that should be option.
  3. Oli Bartsch commented on patch set 11 12/10/19, 09:55

    ExecuteSchedulableCommandAdditionalFieldProvider.php:91 Reply

    Ack

    ExecuteSchedulableCommandAdditionalFieldProvider.php:285 Reply

    Ack
  4. Sebastian Mazza uploaded patch set 12 12/10/19, 15:14

  5. TYPO3com voted on patch set 12 V +1 12/10/19, 15:22 Completed build in 07m 33s on Tue, 10 Dec, 03:22 PM Test Summary: 68709 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39308

  6. Sebastian Mazza uploaded patch set 13 12/12/19, 12:43

  7. Sebastian Mazza commented on patch set 13 12/12/19, 12:54

    I have added a validation for every single item of an option with mode: (InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED). After experimenting with command line option parser of symfony commands, I think this is a more consistent and secure behaviour.
  8. TYPO3com voted on patch set 13 V -1 12/12/19, 13:42 Completed build in 58m 29s on Thu, 12 Dec, 01:42 PM Test Summary: 11 of 69166 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39360

  9. TYPO3com voted on patch set 13 V +1 12/15/19, 15:38 Completed build in 3h 53m 36s on Sun, 15 Dec, 03:38 PM Test Summary: 68715 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39360

  10. Tomas Norre Mikkelsen voted on patch set 13 CR +1 12/30/19, 15:30

  11. Benni Mack voted on patch set 13 V +1 CR +1 12/30/19, 22:04

  12. Guido Schmechel commented on patch set 13 12/31/19, 10:54

    ExecuteSchedulableCommandAdditionalFieldProvider.php:144 Unresolved

    Maybe we should save $optionDefinition->getName() in a variable? The content is used three times here.
  13. Benni Mack uploaded patch set 14 01/15/20, 11:36

  14. TYPO3com voted on patch set 14 V -1 01/15/20, 11:45 Completed build in 08m 51s on Wed, 15 Jan, 11:45 AM Test Summary: 69524 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39963

  15. Sebastian Mazza voted on patch set 14 V +1 CR +1 01/15/20, 17:47

  16. TYPO3com voted on patch set 14 V +1 01/15/20, 21:41 Completed build in 10h 13m 38s on Wed, 15 Jan, 09:41 PM Test Summary: 69524 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39963

  17. Sascha Rademacher voted on patch set 14 V +1 CR +1 01/16/20, 08:40

  18. Daniel Goerz uploaded patch set 15 01/16/20, 10:42

  19. Daniel Goerz voted on patch set 15 V +1 CR +1 01/16/20, 10:42

  20. TYPO3com voted on patch set 15 V +1 01/16/20, 11:57 Completed build in 1h 13m 17s on Thu, 16 Jan, 11:57 AM Test Summary: 70367 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-40025

  21. Sascha Rademacher voted on patch set 15 V +1 CR +1 01/16/20, 12:21

  22. Susi Moog voted on patch set 15 V +1 CR +1 01/16/20, 12:29

  23. Daniel Goerz voted on patch set 15 V +2 CR +2 01/16/20, 12:31

  24. Daniel Goerz merged patch set 16 01/16/20, 12:31

  25. Felix P. voted on patch set 16 V +1 CR +1 01/16/20, 12:55