Project

General

Profile

Actions

Bug #96588

open

URI to backend module can only be generated from BE context

Added by Philipp Kitzberger over 2 years ago. Updated over 1 year ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-01-19
Due date:
% Done:

0%

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

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]);

https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/BackendRouting/Index.html#generating-backend-urls

Actions #1

Updated by Georg Ringer about 2 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?

Actions #2

Updated by Philipp Kitzberger about 2 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/ ;-(

Actions #3

Updated by Philipp Kitzberger about 2 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

Actions #4

Updated by B. Kausch almost 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

Actions #5

Updated by Riccardo De Contardi almost 2 years ago

  • Status changed from Needs Feedback to New
Actions #6

Updated by Benni Mack over 1 year 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?

Actions

Also available in: Atom PDF