Bug #96588
openURI to backend module can only be generated from BE context
0%
Description
It seems not possible to create absolute links from the frontend to a certain backend module, is it?
Use case might be a mail triggered by a frontend user action sent to an admin, so they log into the TYPO3 backend to check that users generated input.
I've tried both ways, fluid viewhelper and php, but the resulting URI is always missing the /typo3/
slug!
fluid viewhelper: <f:be.link route="web_layout">click me</f:be.link>
php:
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uri = $uriBuilder->buildUriFromRoute('web_layout', ['id' => $pageId]);
Updated by Georg Ringer almost 3 years ago
- Status changed from New to Needs Feedback
just had the following in a frontend extbase controller
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 1]); DebuggerUtility::var_dump((string)$uri);die;
and the response was
'/typo3/module/web/layout?token=4e758c7b691c39057750b59ec97725d3374efbb1&id=1'
tested in latest 11 branch, can you recheck?
Updated by Philipp Kitzberger almost 3 years ago
I've tried it with TYPO3 version 11.5.6 and all of the 3rd parameters of that method. Here's the results:
UriBuilder::ABSOLUTE_PATH (which is the default)
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::ABSOLUTE_PATH);
=> /typo3/module/web/layout?token=23a6b3c1eebccd55516c9b594a53c939dac047c7&id=700
UriBuilder::ABSOLUTE_URL
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::ABSOLUTE_URL);
=> http://my.domain.dev:8080/module/web/layout?token=23a6b3c1eebccd55516c9b594a53c939dac047c7&id=700
UriBuilder::SHAREABLE_URL
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::SHAREABLE_URL);
=> http://my.domain.dev:8080/module/web/layout?id=700
Only ABSOLUTE_PATH seems to be prepending the backend segment /typo3/
;-(
Updated by Philipp Kitzberger almost 3 years ago
Within a CLI task (Symfony Console Command) it's like this:
UriBuilder::ABSOLUTE_PATH
=> /typo3/module/web/layout?token=79dfeab622fc864f653bc331c9b5dddae1a53373&id=700
UriBuilder::ABSOLUTE_URL
=> http://bin/module/web/layout?token=2db3ed68adb23c7b443554f6f7eba659331c1792&id=700
UriBuilder::SHAREABLE_URL
=> http://bin/module/web/layout?id=700
Updated by B. Kausch over 2 years ago
This is clearly a bug. You can't build shareable backend urls in frontend context (which is a perfectly possible case). The problem is this line: https://forge.typo3.org/projects/typo3cms-core/repository/1749/revisions/master/entry/typo3/sysext/backend/Classes/Routing/UriBuilder.php#L182
Updated by Riccardo De Contardi over 2 years ago
- Status changed from Needs Feedback to New
Updated by Benni Mack about 2 years ago
- Status changed from New to Needs Feedback
Hey,
yes. this was not possible until now, as we've been having a hard time with all the GeneralUtility::getIndpEnv() calls.
In v12, we've overcome this with a proper "BackendEntryPointResolver" class, see https://review.typo3.org/c/Packages/TYPO3.CMS/+/75620 - can you recheck?