Project

General

Profile

Actions

Bug #91625

closed

UriBuilder: inconsistent behaviour between application contexts Development + Production

Added by Michael Stopp over 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2020-06-09
Due date:
% Done:

100%

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

Description

I have a class method that gets called by a hook of felogin.

In this method I use the uriFor() method of UriBuilder to build a redirect URL. This works without a problem in my development environment, which runs in application context Development.

After installing the extension in the live environment (running in application context Production), I ran into constant problems. Building the redirect URL works maybe once in ten attempts. For the rest of the time it fails with "Call to a member function typoLink_URL() on null", which seems to be caused by $this->contentObject not being set in buildFrontendUri(). I haven't found out yet, why it works sometimes. I tried clearing caches and reloading and what not. I then switched the live environment to application context Development and everything works again without a problem.

This raises several questions:

1) What's going on? Why does it occasionally work? I know there can be issues when UriBuilder is called in special situations (eg. scheduler tasks, command controllers), but here we are in FE mode, so what's the problem? (According to the API docs this "Works in Frontend and Backend mode of TYPO3".)

2) Why can code, which was written in application context Development, not safely be used in Production? That seems to defy the whole point of application contexts. Why should I even bother to develop in application context Development, if I can't be sure that it will later work in the live environment?


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #95118: Unable to use UriBuilder outside ExtbaseClosed2021-09-06

Actions
Related to TYPO3 Core - Bug #95265: Revert injection of ContentObjectRenderer in UriBuilderRejectedBenni Mack2021-09-17

Actions
Actions #1

Updated by Christian Eßl over 4 years ago

Which TYPO3 9 version was used? Does updating to the latest version (9.5.19) fix the problem?
I just happened to stumble upon the same problem in 8.7.32 and I'm curious if this problem is related to recent problems with the Extbase ReflectionService that were fixed in the last minor patches. AFAIK this problem should be relatively new.

As a "hotfix" you could also do the following to manually set up the ContentObject:

/** @var ConfigurationManager $configurationManager */
$configurationManager = $this->objectManager->get(ConfigurationManager::class);

/** @var ContentObjectRenderer $contentObjectRenderer */
$contentObjectRenderer = $this->objectManager->get(ContentObjectRenderer::class);
$configurationManager->setContentObject($contentObjectRenderer);

$uriBuilder = $this->objectManager->get(UriBuilder::class);
$uriBuilder->injectConfigurationManager($configurationManager);

// now use UriBuilder
Actions #2

Updated by Christopher Kaster over 4 years ago

Christian Eßl wrote:

Which TYPO3 9 version was used? Does updating to the latest version (9.5.19) fix the problem?
I just happened to stumble upon the same problem in 8.7.32 and I'm curious if this problem is related to recent problems with the Extbase ReflectionService that were fixed in the last minor patches. AFAIK this problem should be relatively new.

As a "hotfix" you could also do the following to manually set up the ContentObject:

[...]

I can confirm we have this issue with TYPO3 v9.5.19 as well, I'll try the workaround in a bit.

Edit: Workaround works :)

Actions #3

Updated by Michael Stopp over 4 years ago

@Christian Eßl: sorry, I somehow missed your comment...

Yes, this was done with the latest V9 version.

As for your workaround: can't test this easily right now, because I had rewritten the code without UriBuilder, using something like this:

$additionalParams = HttpUtility::buildQueryString($arguments, '&');
$conf = [
    'parameter' => $this->settings['targetPage'],
    'additionalParams' => $additionalParams
];
$uri = $GLOBALS['TSFE']->cObj->typoLink_URL($conf);
Actions #4

Updated by Gerrit Code Review over 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/69132

Actions #5

Updated by Gerrit Code Review over 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/69132

Actions #6

Updated by Gerrit Code Review over 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/69132

Actions #7

Updated by Gerrit Code Review over 3 years ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/69133

Actions #8

Updated by Gerrit Code Review over 3 years ago

Patch set 2 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/69133

Actions #9

Updated by Benni Mack over 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Torben Hansen about 3 years ago

  • Related to Bug #95118: Unable to use UriBuilder outside Extbase added
Actions #11

Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed
Actions #12

Updated by Benni Mack about 3 years ago

  • Related to Bug #95265: Revert injection of ContentObjectRenderer in UriBuilder added
Actions

Also available in: Atom PDF