Project

General

Profile

Actions

Bug #88739

open

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

Added by Jens Jacobsen over 4 years ago. Updated almost 4 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2019-07-12
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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>

Files

unprotected_page_setup.png (194 KB) unprotected_page_setup.png No access restriction on these pages Jens Jacobsen, 2019-07-12 14:14
site_configuration.png (90.3 KB) site_configuration.png Site configuration Jens Jacobsen, 2019-07-12 14:15
titles_and_slugs_for_pages.png (41.5 KB) titles_and_slugs_for_pages.png Titles and their slugs in table pages Jens Jacobsen, 2019-07-12 14:16
incorrect_links_for_de_and_fr.png (568 KB) incorrect_links_for_de_and_fr.png Incorrect links to de and fr version of access restricted page Jens Jacobsen, 2019-07-12 14:17
typo3_development-localhost-12.07.19 (5.76 MB) typo3_development-localhost-12.07.19 Database dump Jens Jacobsen, 2019-07-12 14:19
uribuilder.zip (4.25 KB) uribuilder.zip Demo extension for the dump Jens Jacobsen, 2019-07-12 14:20
protected_page_setup.png (151 KB) protected_page_setup.png Protected page setup Jens Jacobsen, 2019-07-12 14:26
config.yaml (870 Bytes) config.yaml Site configuration yaml Jens Jacobsen, 2019-07-12 14:29
Screenshot 2019-07-16 09.16.27.png (642 KB) Screenshot 2019-07-16 09.16.27.png TYPO3 8.7.27 + ext:realurl 2.5.0 Jens Jacobsen, 2019-07-16 09:17
frontend-link-translated-access-restricted2.diff (4.23 KB) frontend-link-translated-access-restricted2.diff Alexander Stehlik, 2019-10-23 20:32
Actions #1

Updated by Jens Jacobsen over 4 years ago

  • File deleted (protected_page_setup.png)
Actions #3

Updated by Jens Jacobsen over 4 years ago

Actions #4

Updated by Tymoteusz Motylewski over 4 years ago

  • Assignee deleted (Tymoteusz Motylewski)

was this working in v8.7?

Actions #5

Updated by Jens Jacobsen over 4 years ago

Tymoteusz Motylewski wrote:

was this working in v8.7?

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

Actions #6

Updated by Jens Jacobsen over 4 years ago

Jens Jacobsen wrote:

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

Works in TYPO3 8.7.27 and realurl 2.5.0

Actions #7

Updated by Alexander Stehlik over 4 years ago

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.

Actions #8

Updated by Renato Morell about 4 years ago

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.

Actions #9

Updated by Jonas Eberle almost 4 years ago

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)

Actions #10

Updated by Jonas Eberle almost 4 years ago

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

Actions

Also available in: Atom PDF