Bug #89445

FooterAsset are not loaded

Added by Michal Majernik about 1 month ago. Updated 27 days ago.

Status:
Resolved
Priority:
Should have
Category:
Content Rendering
Target version:
-
Start date:
2019-10-18
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
7.2
Tags:
footer assets, fluid
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

Assets in the FooterAssets section are no longer rendered.

How to reproduce:

Create a simple indexAction, Index.html template and a simple js file (i.e. feature.js)

When you add FooterAssets section into your Index.html template as follows:

<f:section name="FooterAssets">
    <script type="application/javascript" src="{f:uri.resource(path:'JavaScript/feature.js', extensionName: 'MyExtension')}"></script>
</f:section>

then this javascipt won't be rendered


Related issues

Related to TYPO3 Core - Feature #88689: Support for system-wide class dependency injection, PSR-11 Closed 2019-07-05
Related to TYPO3 Core - Bug #68061: Ensure PageRenderer singleton is set Closed 2015-07-12
Related to TYPO3 Core - Bug #87402: Feature-79409 renderAssetsForRequest does not work for USER_INT/uncached Resolved 2019-01-11

Associated revisions

Revision cffb6e0f (diff)
Added by Daniel Goerz 27 days ago

[BUGFIX] Use GeneralUtility for initialization of PageRenderer

The PageRenderer is set via GeneralUtility::setSingletonInstance()
by TSFE. This circumvents the DI concept and has to be removed in
the long term. It leads to the situation where makeInstance()
returns a different instance of the PageRenderer than the global DI
does.

To restore the functionality we instanciate the PageRenderer with
makeInstance() for now and will follow-up with another patch later
on to remove setSingletonInstance() usages outside of tests.

Resolves: #89445
Releases: master
Change-Id: I08846cb6592f40e5853f1ca9476969d64b7c4cce
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62033
Tested-by: TYPO3com <>
Tested-by: Benjamin Franzke <>
Tested-by: Susanne Moog <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Benjamin Franzke <>
Reviewed-by: Susanne Moog <>

History

#1 Updated by Daniel Goerz about 1 month ago

  • Status changed from New to Accepted
  • Is Regression set to Yes

Hi Michal,
thanks for reporting. I could verify the issue.

It seems related to the newly introduced Dependency Injection and the initialization of the PageRenderer class in the ActionController.

If you need a quick fix, you can override the method in your controller with the following:

protected function renderAssetsForRequest($request)
{
    if (!$this->view instanceof TemplateView) {
        return;
    }
    $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
    $variables = ['request' => $request, 'arguments' => $this->arguments];
    $headerAssets = $this->view->renderSection('HeaderAssets', $variables, true);
    $footerAssets = $this->view->renderSection('FooterAssets', $variables, true);
    if (!empty(trim($headerAssets))) {
        $pageRenderer->addHeaderData($headerAssets);
    }
    if (!empty(trim($footerAssets))) {
        $pageRenderer->addFooterData($footerAssets);
    }
}

#2 Updated by Benjamin Franzke about 1 month ago

  • Assignee set to Benjamin Franzke

#3 Updated by Daniel Goerz 30 days ago

After talking to Benjamin we figured out, that indeed makeInstance and OM->get() return different objects here

$pageRenderer = $this->objectManager->get(PageRenderer::class);
spl_object_id($pageRenderer); // 946
spl_object_hash($pageRenderer); // 000000002101b3d70000000020f34487
$pageRenderer2 = GeneralUtility::makeInstance(PageRenderer::class);
spl_object_id($pageRenderer2); // 1045
spl_object_hash($pageRenderer2); // 000000002101b3d70000000020f34487

The reason is that TSFE sets a PageRendererInstance via setSingletonInstance() which is then only respected by instantiantion via GU::makeInstance().
The symfony DI container and therefore the ObjectManager do not now anything about this singleton cache.

The goal is to remove setSingletonInstance() from usage outside of tests completely.

#4 Updated by Daniel Goerz 30 days ago

  • Related to Feature #88689: Support for system-wide class dependency injection, PSR-11 added

#5 Updated by Daniel Goerz 30 days ago

  • Related to Bug #68061: Ensure PageRenderer singleton is set added

#6 Updated by Gerrit Code Review 27 days ago

  • Status changed from Accepted 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/+/62033

#7 Updated by Gerrit Code Review 27 days 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/+/62033

#8 Updated by Daniel Goerz 27 days ago

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

#9 Updated by Daniel Goerz 23 days ago

  • Related to Bug #87402: Feature-79409 renderAssetsForRequest does not work for USER_INT/uncached added

Also available in: Atom PDF