Bug #88739
openUriBuilder does not generate correct uri's for access restricted pages when using more than one language
0%
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
Updated by Jens Jacobsen over 5 years ago
- File deleted (
protected_page_setup.png)
Updated by Jens Jacobsen over 5 years ago
- File protected_page_setup.png protected_page_setup.png added
Updated by Tymoteusz Motylewski over 5 years ago
- Assignee deleted (
Tymoteusz Motylewski)
was this working in v8.7?
Updated by Jens Jacobsen over 5 years ago
Tymoteusz Motylewski wrote:
was this working in v8.7?
Haven't tested it yet, but could do it.
Updated by Jens Jacobsen over 5 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
Updated by Alexander Stehlik about 5 years ago
- File frontend-link-translated-access-restricted2.diff frontend-link-translated-access-restricted2.diff added
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.
Updated by Renato Morell over 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.
Updated by Jonas Eberle over 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)
Updated by Jonas Eberle over 4 years ago
In my opinion the `setLinkAccessRestrictedPages` should just be deprecated and proper typolink setup be enforced.