#111730Provide soft references as value objects
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
- 98379[FEATURE] Select linkvalidator linktypes by the link type
- 98380[TASK] Deprecate the array representation of soft references
- 98378[TASK] Replace soft reference tokens in one place
- 98377[FEATURE] Provide soft references in AppendLinkHandlerElementsEvent
- 98363[FEATURE] Provide soft references as value objects
History 03
-
Gerrit Code Review pushed patch set 1 for main to change 98363 status
NewUnder Review 12/05/26, 12:51 -
Gerrit Code Review pushed patch set 2 for main to change 98363 12/05/26, 19:50
-
Gerrit Code Review pushed patch set 3 for main to change 98363 12/05/26, 21:50