Project

General

Profile

Actions

Bug #93236

closed

RequireJS Error at backend login

Added by Kevin Appelt over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Backend JavaScript
Target version:
Start date:
2021-01-06
Due date:
% Done:

100%

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

Description

I need to add a JS lib to the backend (more precisely to the backend login) which worked fine in v10 - and works fine in v11 after logging into the backend.

On login screen I can see an error 500 in the browser console (coming from requirejs-loader.js:67), which is the result of

Symfony\Component\Routing\Exception\ResourceNotFoundException
No routes found for "/ajax/core/requirejs&name=nameOfTheLibToLoad".

As said, the error is gone when logged in to the backend and the file is loaded as required.

This is the code, which registers the lib.

$pageRenderer->addRequireJsConfiguration([
    'shim' => [
        'nameOfTheLibToLoad' => [
            'exports' => 'nameOfTheLibToLoad'
        ]
    ],
    'paths' => [
        'nameOfTheLibToLoad' => PathUtility::getAbsoluteWebPath(
            ExtensionManagementUtility::extPath(
                'myext',
                'Resources/Public/JavaScript/'
            )
        )
            . 'filenameOfTheLibToLoadWithoutDotJs'
    ]
]);

This code works as expected (but fails due to the missing lib)

$pageRenderer->loadRequireJsModule('TYPO3/CMS/Myext/FileWithoutDotJs');

Actions #1

Updated by Andreas Kienast over 3 years ago

  • Status changed from New to Needs Feedback

This seems to be fixed with #93227. Can you please check this with the latest master?

Actions #2

Updated by Kevin Appelt over 3 years ago

On current master the problem changes a little bit but is still present.

What i cann see in the browser console:

ajax/core/requirejs?name=nameOfTheLibToLoad:1 Failed to load resource: the server responded with a status of 404 ()

So it is not an error 500, but a 404 now.

Unchanged:
- problem is gone as soon as the user is logged in

Actions #3

Updated by Benjamin Franzke over 3 years ago

Where do you invoke $pageRenderer->addRequireJsConfiguration(…)?

Which hook/event are you using?

Actions #4

Updated by Benni Mack about 3 years ago

  • Target version changed from 11.1 to 11.2
Actions #5

Updated by Riccardo De Contardi about 3 years ago

  • Category set to Backend JavaScript
Actions #6

Updated by Benni Mack almost 3 years ago

  • Target version changed from 11.2 to 11.3
Actions #7

Updated by Benni Mack almost 3 years ago

  • Target version changed from 11.3 to 11.4
Actions #8

Updated by Benni Mack over 2 years ago

  • Target version changed from 11.4 to 11 LTS
Actions #9

Updated by Kevin Appelt over 2 years ago

I've prepared an extension to check the issue: https://github.com/kevin-appelt/TrianglifyBackground
In TYPO3 Version 10 everything is fine.
In TYPO3 Version 11 the code does not work.

Actions #10

Updated by Gerrit Code Review over 2 years ago

  • Status changed from Needs Feedback 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/+/71389

Actions #11

Updated by Benjamin Franzke over 2 years ago

Thanks for the example extension.

So the issue basically happens because you're adding the configuration in ext_localconf.php in TYPO3 v10, but via PageRenderer render-preProcess in TYPO3 v11.
So two completely different codepaths

Sure, you do this because TYPO3 core does the same for rte_ckeditor and t3editor since #92848.

Now, the issue is that since RequireJS configuration is loaded ondemand (with a separate AJAX request) at the TYPO3 backend login screen for security reasons (see #83855). In that context the hook is never executed (neither in v10 nor in v11)
And because of that it would have failed in TYPO3 v10 as well, if you would have used the hook there.

Now, what is the difference between rte_ckeditor and t3editor and your extension?
These core extensions don't require their configuration to be available during backend login, therefore the usage of the render-preProcess hook is ok(ish), while not perfect.

But render-preProcess has never been an explicit post-configuration API.

I'm not sure whether we really want to officially support that – if so https://review.typo3.org/c/Packages/TYPO3.CMS/+/71389 would solve this issue – or if we rather introduce a new Event that allows to modify requirejs configuration and use that in core as well.

Actions #12

Updated by Gerrit Code Review over 2 years ago

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/+/71395

Actions #13

Updated by Benjamin Franzke over 2 years ago

An alternative would be to avoid the hook and rather fix addRequireJsConfiguration to work without conditions in ext_localconf.php

Implementation would be as follows:

71395: [BUGFIX] Fix PageRenderer->addRequireJsConfiguration from ext_localconf | https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395

Adaption for the demo extension:
https://github.com/bnf/TrianglifyBackground/commit/no-hook

Actions #14

Updated by Gerrit Code Review over 2 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/+/71395

Actions #15

Updated by Gerrit Code Review over 2 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/+/71395

Actions #16

Updated by Gerrit Code Review over 2 years ago

Patch set 4 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/+/71395

Actions #17

Updated by Gerrit Code Review over 2 years ago

Patch set 5 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/+/71395

Actions #18

Updated by Benjamin Franzke over 2 years ago

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

Updated by Benni Mack over 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF