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 5 years ago.
Updated over 4 years ago.
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
|
|
- File deleted (
protected_page_setup.png)
- Assignee deleted (
Tymoteusz Motylewski)
was this working in v8.7?
Tymoteusz Motylewski wrote:
was this working in v8.7?
Haven't tested it yet, but could do it.
Jens Jacobsen wrote:
Haven't tested it yet, but could do it.
Works in TYPO3 8.7.27 and realurl 2.5.0
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.
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.
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)
In my opinion the `setLinkAccessRestrictedPages` should just be deprecated and proper typolink setup be enforced.
Also available in: Atom
PDF