Bug #93236

RequireJS Error at backend login

Added by Kevin Appelt 10 months ago. Updated 21 days 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');

#1

Updated by Andreas Fernandez 10 months ago

  • Status changed from New to Needs Feedback

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

#2

Updated by Kevin Appelt 10 months 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

#3

Updated by Benjamin Franzke 10 months ago

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

Which hook/event are you using?

#4

Updated by Benni Mack 8 months ago

  • Target version changed from 11.1 to 11.2
#5

Updated by Riccardo De Contardi 7 months ago

  • Category set to Backend JavaScript
#6

Updated by Benni Mack 6 months ago

  • Target version changed from 11.2 to 11.3
#7

Updated by Benni Mack 3 months ago

  • Target version changed from 11.3 to 11.4
#8

Updated by Benni Mack about 2 months ago

  • Target version changed from 11.4 to 11 LTS
#9

Updated by Kevin Appelt 28 days 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.

#10

Updated by Gerrit Code Review 28 days 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

#11

Updated by Benjamin Franzke 28 days 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.

#12

Updated by Gerrit Code Review 28 days 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

#13

Updated by Benjamin Franzke 28 days 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

#14

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

#15

Updated by Gerrit Code Review 27 days 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

#16

Updated by Gerrit Code Review 27 days 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

#17

Updated by Gerrit Code Review 27 days 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

#18

Updated by Benjamin Franzke 27 days ago

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

Updated by Benni Mack 21 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF