WapplerSystems / ws_less

less compiler extension for TYPO3
GNU General Public License v2.0
7 stars 24 forks source link

PHP Warning: Undefined global variable $TSFE in RenderPreProcessorHook.php line 81 #29

Open StanislavSeifert opened 1 year ago

StanislavSeifert commented 1 year ago

Got "Undefined global variable $TSFE" warning in backend: warning_screenshot

It look like that $GLOBALS['TSFE'] will be initialized after the "renderPreProcessorProc" hook.

Enviroment: TYPO3 Version: 11.5.17 Webserver: Apache/2.4.54 (Debian) PHP Version: 8.1.11 wapplersystems/ws_less: "^11.0"

Following patch will solve the problem:

IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Hooks/RenderPreProcessorHook.php b/Classes/Hooks/RenderPreProcessorHook.php
--- a/Classes/Hooks/RenderPreProcessorHook.php
+++ b/Classes/Hooks/RenderPreProcessorHook.php  (date 1665767227441)
@@ -78,7 +78,9 @@

         $sitePath = Environment::getPublicPath() . '/';

-        $setup = $GLOBALS['TSFE']->tmpl->setup;
+        $configurationManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
+        $setup = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
+
         if (\is_array($setup['plugin.']['tx_wsless.']['variables.'])) {

             $variables = $setup['plugin.']['tx_wsless.']['variables.'];

Please update this extension.

danielDigitalArt commented 5 months ago

Actually a fix exists (https://github.com/WapplerSystems/ws_less/commit/5493d624ef3005be7ef39b9fff9d9e71cd1c66cf) but it was only included in version 12, thus there is currently no version available working on typo3 11.

On Typo3 11.5.33 i just installed Version 11.0 nd instantly got the same Error (PHP Warning: Undefined global variable $TSFE)

Solution would be to make a Version 11.0.1 which has this fix.