Review main Merged

90400[TASK] Add `getSoftReferenceKeys()` method to Schema Field API

Oli Bartsch CR +2 V +2 Hard +280 −7 updated 08/15/25, 13:17

Commit message

This introduces a new method `getSoftReferenceKeys()` to the
`FieldTypeInterface` that allows programmatic detection of fields
with soft reference configurations. This enables automatic
discovery of fields containing soft references without manual
maintenance of field lists.

The method returns:
- `false` if soft references are not supported by the field type or
  no softRef configuration key exists at all
- `array` (possibly empty) when softRef configuration is present

The explicit `false` return value is necessary to distinguish between:
- Field types that cannot / should not have soft references (returns false)
- Field types that support soft references but have no parsers configured
  (returns empty array)
- Field types with actual soft reference parsers (returns parser keys array)

This distinction allows consumers to differentiate between "soft
references not supported" vs "soft references supported but not
configured", which is important for components like LinkValidator
that need to know whether to even consider soft references on a field.

Key changes:
- Added `getSoftReferenceKeys(): array|false` to FieldTypeInterface
- Implemented default logic in AbstractFieldType to parse comma-separated
  `softRef` configuration using `GeneralUtility::trimExplode()`
- Override method to return `false` for field types that logically
  can't contain soft references (checkbox, number, passthrough, etc.)

This change enables components like LinkValidator to automatically
discover fields with soft reference configurations, making manual
declaration of TSconfig "searchFields" obsolete.

Review

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

Issues 1

Files 30

Show 10 more files

Review log 1319

  1. Oli Bartsch uploaded patch set 1 08/14/25, 15:06

  2. Oli Bartsch updated the commit message in patch set 2 08/14/25, 15:06

  3. Mathias Brodala commented on patch set 2 08/14/25, 15:10

    Do we need "false"? Would an empty array as return value not work equally well?
  4. core-ci voted on patch set 1 V -1 08/14/25, 15:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83396

  5. core-ci voted on patch set 2 V -1 08/14/25, 15:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83397

  6. Oli Bartsch uploaded patch set 3 V -1 08/14/25, 15:17

  7. core-ci voted on patch set 3 V +1 08/14/25, 15:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83399

  8. Oli Bartsch uploaded patch set 4 V +1 08/14/25, 15:28

  9. Oli Bartsch commented on patch set 4 08/14/25, 15:30

    Reply

    Hi Mathias, the `false` case is explicit needed for better distinction, see the updated commit message.
  10. core-ci voted on patch set 4 V +1 08/14/25, 15:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83400

  11. Oli Bartsch uploaded patch set 5 V +1 08/14/25, 21:46

  12. core-ci voted on patch set 5 V -1 08/14/25, 21:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83414

  13. Oli Bartsch uploaded patch set 6 V -1 08/15/25, 08:47

  14. core-ci voted on patch set 6 V +1 08/15/25, 08:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83441

  15. Benni Mack voted on patch set 6 CR +1 V +1 08/15/25, 10:35

  16. Stefan Bürk commented on patch set 6 08/15/25, 12:58

    CategoryFieldType.php:60

    I'm not sure with making return type stricter in extending types only returning false. That gives consumers with static code anlyzers headaches to work around without real benefit - an we are going to shoot us in our own foot in the future: https://phpstan.org/r/976aec84-5b36-4927-9e74-8e251b817b53 As soon as the "concrete" type is clear, like CategoryFieldType callint that method as part of a condition is considered use-less by phpstan (and I guess psalm too) as it always returns false ... which makes that metod with the interface only usable as the interface is the annotated type and not resolved. Just commenting it here ... that has not been taking into account for other methods and apis already and I guess we need to think about that more in general for the future about the caveats, for ourself but also extension developers. Not taking that now as an blocker.
  17. Stefan Bürk voted on patch set 6 CR +1 V +1 08/15/25, 12:58

  18. Oli Bartsch voted on patch set 6 CR +2 V +2 08/15/25, 13:17

  19. Oli Bartsch merged patch set 7 08/15/25, 13:17