Issue Feature Resolved

#94086Softref for custom linkhandler

Philipp Kitzberger 05/07/21, 02:21 updated 10/23/26, 14:05

Description

In our project we’ve got a custom linkhandler set up that works with external entities and the following link format: t3 ://foo?subtype=bar&identifier=123

Just to be clear: it’s not a record linkhandler!

When trying to config the EXT:linkvalidator we’ve noticed that it uses the “softref index” to identify the links to be validated.

tt_content.bodytext is configured via TCA to have this softref configuration: typolink_tag,email[subst],url

In \TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_typolink_tag only these types seem to be processed though:

if ($linkDetails['type'] === LinkService::TYPE_FILE && preg_match('/file\?uid=(\d+)/', $matches[1], $fileIdMatch)) {
    ...
} elseif ($linkDetails['type'] === LinkService::TYPE_PAGE && preg_match('/page\?uid=(\d+)#?(\d+)?/', $matches[1], $pageAndAnchorMatches)) {
    ...    
} elseif ($linkDetails['type'] === LinkService::TYPE_URL) {
    ...
} elseif ($linkDetails['type'] === LinkService::TYPE_EMAIL) {
    ...
} elseif ($linkDetails['type'] === LinkService::TYPE_TELEPHONE) {
    ...
}

Am I right that LinkService::TYPE_RECORD and our custom linkhandler is not being processed at the moment? Just to be sure before investing time and creating a patch ;-)

Reviews 2

Files 1

History 1720

  1. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2021-11-25T11:00:24+00:00" > 11/25/21, 11:00 </span>

    Hey Philipp,

    the SoftRefParser has now been completely refactored and is now fully extendable (v11). Can you check if you can now integrate custom Link Handler checks?

  2. corbet dynie commented and changed attached patch <span data-processor="relativetime" data-value="2022-03-11T15:24:28+00:00" > 03/11/22, 15:24 </span>

    I had the same problem with v10.4 and I think it is a bug.
    All soft reference parsers take care of records except typolink_tag.

  3. Oliver Weiss commented <span data-processor="relativetime" data-value="2022-03-29T10:43:16+00:00" > 03/29/22, 10:43 </span>

    corbet dynie wrote in #note-4:
    > I had the same problem with v10.4 and I think it is a bug.
    > All soft reference parsers take care of records except typolink_tag.

    I can confirm this. records are not checked by linkvalidator. I think, this is a must-have.

  4. Philipp Kitzberger commented <span data-processor="relativetime" data-value="2023-02-17T14:51:32+00:00" > 02/17/23, 14:51 </span>

    > Can you check if you can now integrate custom Link Handler checks?

    Thanks, Benni! With the TYPO3 11 implementation of the linkvalidator it was now possible to implement handling for our custom typolink format.

    To cover all cases (links within tt_content.bodytext and dedicated link fields such as tt_content.header_link) I had to implement the following:

    EXT:my_extension/ext_localconf.php

    $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']['custom'] = \MyVendor\MyExtension\LinkValidation\CustomUriValidator::class;

    EXT:my_extension/Configuration/TCA/Overrides/tt_content.php

    $GLOBALS['TCA']['tt_content']['columns']['bodytext']['config']['softref'] .= ',custom';
    $GLOBALS['TCA']['tt_content']['columns']['header_link']['config']['softref'] .= ',custom';

    EXT:my_extension/Configuration/Services.yaml

    services:
      MyVendor\MyExtension\LinkValidation\CustomUriResolver:
        tags:
          - name: event.listener
            event: TYPO3\CMS\Core\DataHandling\Event\AppendLinkHandlerElementsEvent
    
      MyVendor\MyExtension\LinkValidation\CustomUriParser:
        tags:
          - name: softreference.parser
            parserKey: custom
  5. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2023-07-05T19:53:53+00:00" > 07/05/23, 19:53 </span>

    so the only thing now is to create a custom linkvalidator now? Or is something missing with v11? Or maybe just documentation?

  6. Philipp Kitzberger commented <span data-processor="relativetime" data-value="2023-07-06T08:21:03+00:00" > 07/06/23, 08:21 </span>

    @benni, yeah, maybe it’s just documentation now that’s missing. I’m often confused about the docs on these topics to be honest. Linkhandler vs. linkbrowser vs. linkvalidator. I guess the chapter on custom linkvalidators is missing completely? https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/LinkHandling/Index.html

  7. Philipp Kitzberger commented <span data-processor="relativetime" data-value="2023-07-06T08:59:42+00:00" > 07/06/23, 08:59 </span>

    @linawolf, nope, I’m talking about a chapter on “link validation” (which I cannot find in the docs)

  8. Gerrit Code Review pushed patch set 1 for main to change 97054 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2026-10-23T07:43:31+00:00" > 10/23/26, 07:43 </span>

  9. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-23T14:05:13+00:00" > 10/23/26, 14:05 </span>

    Applied in changeset commit:7112602de2160e23c8b8212c8571460ce6d26367.