Review main Ready for review Quiet

95891[BUGFIX] Keep validation errors of an outer validate() call

Georg Ringer CR 0 V 0 Hard +275 −31 updated 11/03/26, 19:58

Commit message

ValidatorResolver caches one base validator conjunction per class
name. A model referring to its own type, directly or through a
collection, is therefore validated by the very same instance that
is validating the outer object at that moment.

validate() started a fresh result on every call, so a nested call
discarded the result of the outer call together with every error
already collected in it. The object was reported as valid without
any message pointing to what happened.

validate() now keeps the result of a running call on a stack and
restores it when the nested call is done.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/91/95891/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/91/95891/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 3

Issues 1

Files 8

Review log 1214

  1. Georg Ringer uploaded patch set 1 09/16/26, 20:20

  2. Georg Ringer commented on patch set 1 09/16/26, 20:26

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 09/16/26, 20:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108719

  4. Simon Schaufelberger commented on patch set 1 09/17/26, 09:02

    should we also backport that to v13?
  5. Georg Ringer commented on patch set 1 10/02/26, 16:22

    IMO no need for 13.x
  6. Simon Schaufelberger commented on patch set 1 10/02/26, 17:36

    Reply

    I mean the bug exists since TYPO3 9, so yeah...
  7. Georg Ringer commented on patch set 1 10/02/26, 17:43

    Reply

    Yes and we even define versions as eol even though those are still used. The core team is responsible for the core and in the end most of us do it in their spare time and even if not, we need to always take extra care if a change is breaking for others. Every Bugfix can be potentially be breaking for people depending on that behavior and the mails, shitstorm is always on us. The bug is there since 9x and nobody cared or maybe just handled it on their own.
  8. Simon Schaufelberger voted on patch set 1 CR +1 V +1 10/02/26, 20:10

  9. Simon Schaufelberger commented on patch set 1 10/02/26, 20:11

    Reply

    Done
  10. Alexander Schnitzler commented on patch set 1 V +1 10/17/26, 06:38

    I would suggest to wrap the inner validation logic into try..finally blocks and to always return the result in the finally block to respect the invariant. A validator that throws can bring down the whole validation stack. It's the right direction but I think this could be a little bit more strict/safe.
  11. Oli Bartsch commented on patch set 1 V -1 10/20/26, 10:16

    AbstractValidator.php:102

    This doesn't tell whether an outer call is still running, because $this->result stays set after every finished call. From the second top-level validate() on, the previous result gets pushed and restored. Between calls the instance then holds the result of its first call, not its latest. This shows wherever $this->result is read outside a running call. The other is custom validators that return $this->result after parent::validate(). Tracking the nesting depth explicitly would fix that, and it would fit together with Alexander's try/finally suggestion.
  12. Georg Ringer uploaded patch set 2 CR +1 V +1 11/03/26, 19:50

  13. Georg Ringer commented on patch set 2 11/03/26, 19:50

    Reply

    Done

    AbstractValidator.php:102 Reply

    Done
  14. core-ci voted on patch set 2 V +1 11/03/26, 19:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113214