Extension is not working with typo3/cms-composer-installers 4.0@rc under TYPO3 11

Issue #53 resolved
Alexander Grein created an issue

In preaparation to a TYPO3 update from 11 to 12 I realized that

after switching from helhum/typo3-secure-web to typo3/cms-composer-installers 4.0@rc under TYPO3 11 this extension stops working.

In the backend the module of this extension looks a bit destroyed (e.g. all icons are gone). In the frontend all my defined entry point are not working anymore.

I just get this json back:

{"status":404,"error":"RestApi-endpoint not found. Based on your request the endpoint would be `Persons::getIndexAction()`","code":404}

For the css problem in the backend I found a relativ easy solution, using the TYPO3 fluid asset viewhelper.

Just replace this code block found in Resources/Private/Backend/Templates/Mod/Error.html and Resources/Private/Backend/Layouts/Module.html:

<link rel="stylesheet" href="/typo3conf/ext/nnhelpers/Resources/Public/Vendor/fontawesome/css/all.css" />
<link rel="stylesheet" href="/typo3conf/ext/nnrestapi/Resources/Public/Vendor/bootstrap.min.css" />
<link rel="stylesheet" href="/typo3conf/ext/nnhelpers/Resources/Public/Css/styles.css" />
<link rel="stylesheet" href="/typo3conf/ext/nnrestapi/Resources/Public/Css/styles.css" />

with this:

<f:asset.css identifier="nnhelpers-fa" href="EXT:nnhelpers/Resources/Public/Vendor/fontawesome/css/all.css" />
<f:asset.css identifier="nnrestapi-bt" href="EXT:nnrestapi/Resources/Public/Vendor/bootstrap.min.css" />
<f:asset.css identifier="nnhelpers-styles" href="EXT:nnhelpers/Resources/Public/Css/styles.css" />
<f:asset.css identifier="nnrestapi-styles" href="EXT:nnrestapi/Resources/Public/Css/styles.css" />

Found two more things to do.
Change Classes/Controller/ModController.php line 50-51 from:

$pageRenderer->addCssFile('/typo3conf/ext/nnhelpers/Resources/Public/Vendor/prism/prism.css');
$pageRenderer->addJsFile('/typo3conf/ext/nnhelpers/Resources/Public/Vendor/prism/prism.js');

To this:

$pageRenderer->addCssFile('EXT:nnhelpers/Resources/Public/Vendor/prism/prism.css');
$pageRenderer->addJsFile('EXT:nnhelpers/Resources/Public/Vendor/prism/prism.js');

The hhhelpers backend module thows this exception:

(1/1) #-1 ReflectionException

Class "" does not exist

Because, this code obviously returns an empty string:

$className = self::getClassNameFromFile( '/var/www/html/vendor/nng/nnhelpers/Classes/Utilities/Arrays.php' );

After further debugging I found that this method returns a wrong path:

$file = \nn\t3::File()->absPath( $file );

It returns
‘/var/www/html/public/var/www/html/vendor/nng/nnhelpers/Classes/Utilities/Arrays.php'
but it should be:
’/var/www/html/var/www/html/vendor/nng/nnhelpers/Classes/Utilities/Arrays.php'

The “public/” part is wrong.

FInally it’s line 336 inside Classes/Utilities/File.php who is responsible for the problem:

$file = ltrim( $file, '/' );

This removes the / from the formerly absolute path. Because of this, the following code detects it as relative and adds the public path with “public/`:

GeneralUtility::getFileAbsFileName($file);

After moving the line 336 below the upper code (after the if) and clearing all caches, my api entry points are working again.

Comments (13)

  1. Log in to comment