Project

General

Profile

Actions

Bug #96464

closed

userFunc in linkhander typolink does not work

Added by Stephan Bauer almost 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2022-01-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I'm trying to use a userFunc in a linkhandler configuration:

config.recordLinks {
  tx_beerdb_domain_model_affiliate {
    typolink {
      userFunc = BU\Beerdb\Hooks\AffiliateTypolink->affiliate
    }
  }
}

The userFunc never gets call.
I found out without a parameter the link generation never comes to the part where the userFunc will be executed.
In sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 5140 because of an empty $linkParamter the function returns to early.
if (!$linkParameter) {
    return $this->resolveAnchorLink($linkText, $conf ?? []);
}

With a litte change

        if (!$linkParameter && !$conf['userFunc']) {
            return $this->resolveAnchorLink($linkText, $conf ?? []);
        }

the userFunc gets call in line 5275 but dynamic values like
userFunc {
    uid = TEXT
    uid.data = FIELD:uid
}

are not evaluated.

Is this a bug or a configuration problem?

Actions #1

Updated by Benni Mack almost 3 years ago

Is this a bug or a configuration problem?

It's a bug, I will fix it.

Actions #2

Updated by Gerrit Code Review almost 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72894

Actions #3

Updated by Gerrit Code Review almost 3 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72894

Actions #4

Updated by Gerrit Code Review almost 3 years ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72916

Actions #5

Updated by Benni Mack almost 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by Gerrit Code Review almost 3 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72916

Actions #7

Updated by Stephan Bauer almost 3 years ago

I added this patch to V 10.4 but still it does not work.
Now only the link text will be returned in line 4632 with return $e->getLinkText();

If I jump over this to reach the call for the userFunc the parameter $content is nearly empty:

array(5 items)
   aTagParams => '' (0 chars)
   url => '' (0 chars)
   TYPE => NULL
   targetParams => '' (0 chars)
   TAG => '<a >' (4 chars)

and $configuration is not resolved
array(3 items)
   uid => 'TEXT' (4 chars)
   uid. => array(1 item)
      data => 'FIELD:uid' (9 chars)
   relAttribute => 'rel="sponsored" class="beer-affiliate-link"' (43 chars)

Actions #8

Updated by Benni Mack almost 3 years ago

  • Status changed from Under Review to Resolved
Actions #9

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF