Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Stale

95639[TASK] Extract a read-only UniquenessChecker from DataHandler

Andreas Nedbal CR 0 V -1 Hard +339 −56 updated 09/04/26, 11:41

Commit message

DataHandler::getUnique() enforces TCA's "unique"/"uniqueInPid" eval
codes by running a COUNT query and, on conflict, appending an
incrementing counter until a free candidate is found or 100 attempts
are exhausted. Both the query and the retry loop assume a save is
imminent: there is no way to ask "is this value free" without going
through DataHandler.

This introduces TYPO3\CMS\Core\Validation\UniquenessChecker, a plain
autowired service exposing that same check without assuming a save
follows: isUnique() answers the yes/no question, findUniqueValue()
runs the same increment-and-retry search DataHandler already did.
Neither persists, logs, or writes anything - the caller decides what
a conflict means.

DataHandler::getUnique() keeps its existing early-return special
case (translation exclusion, based on DataHandler's own in-progress
record state) and its log() call, but now delegates the actual
search to UniquenessChecker::findUniqueValue(), resolved via
GeneralUtility::makeInstance() the same way ItemProcessingService
already is elsewhere in this class.
getUniqueCountStatement() likewise delegates its query building to
UniquenessChecker::buildCountStatement(), rather than keeping a
second copy of it. Both keep their existing signatures.

UniquenessChecker is marked "public: true" in Services.yaml: nothing
else in the container references it via constructor or setter
injection, so without this the container compiler prunes it as
unreferenced and GeneralUtility::makeInstance() fails at runtime -
the same reasoning TextExtractorRegistry already documents for
itself in the same file.

No behavior change: existing DataHandler unit and functional test
suites pass unmodified, including the DataScenarios/UniqueValue
suite that exercises getUnique() directly across regular save,
workspace publish, workspace discard and translation scenarios.

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/39/95639/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/39/95639/2 && git cherry-pick FETCH_HEAD

Review

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

Relation chain 3

  1. 95639 [TASK] Extract a read-only UniquenessChecker from DataHandler This change

  2. main 95638[TASK] Extend FieldValidationService to more TCA field types This change is based on it Work in progress Merge conflict Andreas Nedbal CR 0 V 0 Expert +1000 −180
  3. main 95637[TASK] Introduce FieldValidationService for TCA field validation This change is based on it Work in progress Merge conflict Andreas Nedbal CR 0 V 0 Hard +738 −94

Files 4

Review log 24

  1. Andreas Nedbal uploaded patch set 1 09/04/26, 10:05

  2. core-ci voted on patch set 1 V -1 09/04/26, 10:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107854

  3. Andreas Nedbal rebased onto patch set 2 V -1 09/04/26, 11:28

  4. core-ci voted on patch set 2 V -1 09/04/26, 11:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107859