Review main Merged

86272[BUGFIX] Prevent TypeError on adding extbase validators

Oli Bartsch CR +2 V +2 Easy +7 −8 updated 10/22/24, 14:10

Commit message

ValidatorResolver->createValidator() might return
NULL in case a NoSuchValidatorException is thrown.
This now properly checked.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2123

  1. Oli Bartsch uploaded patch set 1 09/23/24, 21:54

  2. core-ci voted on patch set 1 V +1 09/23/24, 22:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66461

  3. Stefan Bürk voted on patch set 1 CR +1 V +1 09/24/24, 09:46

  4. Oliver Klee commented on patch set 1 09/24/24, 11:29

    ActionController.php:319

    This PHPDoc annotation then is incorrect and should/can be removed. (The native nullable type declaration of `createValidator` is correct.)
  5. Oli Bartsch uploaded patch set 2 CR +1 V +1 09/24/24, 12:23

  6. Oli Bartsch commented on patch set 2 09/24/24, 12:23

    ActionController.php:319 Reply

    Done
  7. core-ci voted on patch set 2 V +1 09/24/24, 12:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66494

  8. Stefan Bürk voted on patch set 2 CR +1 V +1 09/24/24, 12:47

  9. Garvin Hicking commented on patch set 2 V -1 09/25/24, 08:31

    With this patch applied, a form defining an invalid validator will just be submittable. IMO an error/exception must be returned, else an integrator may not know that an invalid validator (spelling error) has been used but is not in effect.
  10. Garvin Hicking commented on patch set 2 CR -1 09/25/24, 08:31

    (tested on a v12 install)
  11. Oli Bartsch commented on patch set 2 09/25/24, 08:34

    Reply

    I agree but for me this is a different topic. This patch is about preventing programming language related errors. Such logic error should be handled differently.
  12. Oli Bartsch commented on patch set 2 09/25/24, 08:39

    Reply

    I just checked again an actually there is already an error logged. Throwing an exception now would be a breaking change.
  13. Garvin Hicking commented on patch set 2 09/25/24, 09:30

    Reply

    Where/how? I am running that v12 in dev context and cannot find an entry either in sys_log or in the var/log logfile. I tested this with a contact form like this: https://gist.github.com/garvinhicking/79618c97134972a84e9592a30237861e First file, line 51 Second file, lines 30-32 I can submit the form without getting an error.
  14. Oli Bartsch commented on patch set 2 09/25/24, 10:09

    Reply

    Here is a log entry generated. https://github.com/TYPO3/typo3/blob/v12.4.20/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php#L59 What happens without this patch? - I assume the TypeError is thrown?
  15. Garvin Hicking commented on patch set 2 09/25/24, 11:35

    Reply

    OK, I see. The extra 'debug' log was not enabled in my case, thanks+sorry ;) I would argue this, however: Without the patch, an exception is thrown. With the patch, the exception no longer happens. It only gets logged to a debug log, which has so much clutter (every authentication info) that probably no one will notice. I would regard this to be a breaking change, because now a very important error is silenced. I would prefer to have a failed validator application throws an exception everywhere, but I see that this would be a breaking change in other places. TL;DR: IMO we need to make sure that an exception for invalid validators is still thrown; better to have that "unclear" than not at all.
  16. Oli Bartsch commented on patch set 2 09/25/24, 12:57

    Reply

    I really don't agree here. There is the `NoSuchValidatorException` thrown and cached on purpose to generate a log entry for. So this has been intended behaviour since ever. The fact that due to strict typing an invalid validator now ends the execution because it leads to a TypeError (error on language level) is not an intended exception handling but a bug, which is fixed with this patch. It could even be argued that due to the TypeError the expected behaviour of having forms with invalid validators are being submitted is broken. Anyways, manually throwing any exception here would a breaking change. As already said in my first comment. I'm fine with talking about a better handling of invalid validators but this must be done by creating a separate issue and a separate patch.
  17. Garvin Hicking commented on patch set 2 CR 0 V 0 09/25/24, 13:33

    Reply

    I just see more dangers from going through with this change than to leave it like it currently is by throwing the exception and stopping the command flow. I think that is the safer way. My -1 was not intented to be blocking, so I'll remove the vote, but I can't vote for it.
  18. Stefan Bürk commented on patch set 2 09/25/24, 14:15

    Reply

    I agree here with both of you. First, Oliver is right and the TypeError should be avoided. In the current implementation and flow it is intented to silence this case/exception and "keep" a working state - thus doing this change is the logical follup on this. The TypeError is a code issue of the core and not a "user notification exception" because he did something bad. However, on the Garvin side I aggree that this might be overthinked and changed, which WOULD be a breakin change to hard throw and (let the exception bubble up). This change legits for a bugfix now - and rethinkg the whole build up and handling in v14 then or so. This is clearly a "let us fix a core missbehaviour / unintended error" aka "bad bug".
  19. Garvin Hicking commented on patch set 2 CR +1 V +1 09/27/24, 11:35

    Let's get this in as-is and maybe talk about it for v14. I can see preventing BC and restoring previous behaviour is the priority now.
  20. Oli Bartsch voted on patch set 2 CR +2 V +2 09/28/24, 10:10

  21. Oli Bartsch merged patch set 3 09/28/24, 10:10

  22. Andreas Kienast commented on patch set 3 10/22/24, 12:44

    AbstractRenderable.php:197

    Why was this change necessary?
  23. Oli Bartsch commented on patch set 3 10/22/24, 14:10

    AbstractRenderable.php:197 Reply

    I actually don't remember. From looking at the patch I assume I did this while doing the necessary return type change, because the method is only used in this class and the class is marked as internal. However, see revert of the visibility change: 86691: [BUGFIX] Revert visibility change of createValidator() | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86691