Issue Feature Under Review

#111730Provide soft references as value objects

Benni Mack 12/05/26, 10:20 updated 12/05/26, 21:50

Description

Soft reference parsers return their matches as nested arrays (“matchString”, “subst” with “type”, “tokenID”, “tokenValue”, “recordRef”, “error”). The shape is only documented in a docblock, the “type” key is interpreted differently by its consumers, and every consumer (reference index, ext:impexp, ext:lowlevel, ext:linkvalidator) has to know the array structure.

SoftReferenceParserResult should provide the matches as value objects:

  • SoftReference: the match string, an optional substitution and an optional error
  • SoftReferenceSubstitution: token ID and value, and whether it points to a record (table and uid) or is a plain value
  • SoftReferenceTargetType: Record (“db”) or Value (“string”)

Parsers can create the result from these objects with SoftReferenceParserResult::fromSoftReferences(), consumers read them with getSoftReferences(). Results created from arrays with create() keep working and are converted. getMatchedElements() still returns the array representation.

The reference index uses the objects to create its rows. The array representation of ReferenceIndex::getRelations() is unchanged, it is part of the export files of ext:impexp.

Follow-ups: migrate ext:impexp, ext:lowlevel and ext:linkvalidator and the typolink parsers (AppendLinkHandlerElementsEvent) to the objects, then deprecate the array representation.

Related: #107184

Reviews 5

History 03

  1. Gerrit Code Review pushed patch set 1 for main to change 98363 status New Under Review 12/05/26, 12:51

  2. Gerrit Code Review pushed patch set 2 for main to change 98363 12/05/26, 19:50

  3. Gerrit Code Review pushed patch set 3 for main to change 98363 12/05/26, 21:50