Issue Bug Resolved

#88739UriBuilder does not generate correct uri's for access restricted pages when using more than one language

Jens Jacobsen 07/12/19, 14:20 updated 10/17/26, 13:44

Description

In TYPO3 9.5 or later, the UriBuilder from extbase cannot create correct translated links for access restricted in other languages than default.

Code used to generate the links from the output

    public function listAction()
    {
        $link = $this->uriBuilder->reset()->setTargetPageUid(4)->build();
        $linkWithRemovedAccessRestriction = $this->uriBuilder->reset()->setLinkAccessRestrictedPages(true)->setTargetPageUid(4)->build();
        $linkProtectedPage = $this->uriBuilder->reset()->setLinkAccessRestrictedPages(true)->setTargetPageUid(7)->build();
        $this->view->assign('link', $link);
        $this->view->assign('linkWithRemovedAccessRestriction', $linkWithRemovedAccessRestriction);
        $this->view->assign('linkProtectedPage', $linkProtectedPage);
    }
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">

<p>Link: {link}</p>
<p>Link with removed access restriction: {linkWithRemovedAccessRestriction}</p>
<p>Link to a protected page: {linkProtectedPage}</p>

<f:debug inline="true">{_all}</f:debug>

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Files 10

History 11

  1. Tymoteusz Motylewski commented and changed removed the assignee <span data-processor="relativetime" data-value="2019-07-15T10:46:20+00:00" > 07/15/19, 10:46 </span>

    was this working in v8.7?

  2. Jens Jacobsen commented <span data-processor="relativetime" data-value="2019-07-15T14:51:46+00:00" > 07/15/19, 14:51 </span>

    Tymoteusz Motylewski wrote:
    > was this working in v8.7?

    Haven’t tested it yet, but could do it.

  3. Jens Jacobsen commented and changed attached Screenshot 2019-07-16 09.16.27.png <span data-processor="relativetime" data-value="2019-07-16T09:17:28+00:00" > 07/16/19, 09:17 </span>

    Jens Jacobsen wrote:
    > Haven’t tested it yet, but could do it.

    Works in TYPO3 8.7.27 and realurl 2.5.0

  4. Alexander Stehlik commented and changed attached frontend-link-translated-access-restricted2.diff <span data-processor="relativetime" data-value="2019-10-23T20:33:58+00:00" > 10/23/19, 20:33 </span>

    Linking to access restricted translated pages seems also to be problematic with TypoScript menus. A short example:

    my_menu = HMENU
    my_menu {
        special = list
        special.value = <access restricted pid>
        1 = TMENU
        1.showAccessRestrictedPages = NONE
    }

    The link is not generated a all for the translated page.

    I was able to work around that using the attached patch but still the URL is wrong (based on the default language) as described by Jens. Only workaround for this is to use the same URL for the default language and the translated page.

  5. Renato Morell commented <span data-processor="relativetime" data-value="2020-03-27T14:21:00+00:00" > 03/27/20, 14:21 </span>

    Same problem here. I have 2 sites defined. In the main site (Root PID 1) the URL with the default language slugs works for all languages, but for the second site an error appears.

  6. Jonas Eberle commented <span data-processor="relativetime" data-value="2020-04-26T17:53:17+00:00" > 04/26/20, 17:53 </span>

    I can confirm for v9 and v10.

    Here is my Extbase plugin test action

    {
            $pid = 2; // <- set to an access restricted page
    
            $link = $this->uriBuilder->reset()
                ->setTargetPageUid($pid)
                ->build();
            $linkAccessRestrictedPages = $this->uriBuilder->reset()
                ->setTargetPageUid($pid)
                ->setLinkAccessRestrictedPages(true)
                ->build();
    
            debug(
                [
                    'link' => $link,
                    'linkAccessRestrictedPages' => $linkAccessRestrictedPages,
                ],
                'linking to page uid=' . $pid
            );
            return '';
        }

    I additionally set

    config {
        typolinkLinkAccessRestrictedPages = 1
        typolinkLinkAccessRestrictedPages_addParams = &return_url=###RETURN_URL###&pageId=###PAGE_ID###
    }

    Testing for non-default language:
    With that setup, $link is correct (…&return_url=…) but $linkAccessRestrictedPages is generating invalid URLs (e.g. `/de/4-en` where /de/ is the language but `4-en` is the default language slug -> 404)

  7. Jonas Eberle commented <span data-processor="relativetime" data-value="2020-04-26T17:54:43+00:00" > 04/26/20, 17:54 </span>

    In my opinion the `setLinkAccessRestrictedPages` should just be deprecated and proper typolink setup be enforced.

  8. Alexander Schnitzler commented and changed status New Resolved <span data-processor="relativetime" data-value="2026-10-17T13:44:15+00:00" > 10/17/26, 13:44 </span>

    This is resolved in core. The Extbase UriBuilder only passes linkAccessRestrictedPages = 1 on to typolink; the wrong slug came from the page language overlay, which dropped an access restricted translation for anonymous visitors and fell back to the default language record.

    Fixed by:

    • 56269a975cb “Use correct slug for access restricted translated pages” (#90842, 10.4.2 / 9.5.17)
    • 0127c68c50d (#91725, 11.0.0 / 10.4.10 / 9.5.23)

    Covered by existing tests on main:

    Closing as resolved. If you still see the default language slug on a current version, please open a new issue with the site configuration and the page records (sys_language_uid, l10n_parent, fe_group of the translation). Deprecating setLinkAccessRestrictedPages() would be a separate issue.