From 25ccc28ecc32efae848fc787c97ddffca2901641 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Wed, 10 Aug 2022 18:44:00 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Raise=20dependencies?= =?UTF-8?q?=20to=20include=20TYPO3=20v11=20and=20PHP=208.0=20&=208.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 ++-- ext_emconf.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d39be73..656fbed 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ } }, "require": { - "php": "7.2.0 - 7.4.99", - "typo3/cms-core": "^10.4" + "php": "7.2.0 - 8.1.99", + "typo3/cms-core": "^10.4 || ^11.5" }, "replace": { "typo3-ter/plausible-analytics": "self.version" diff --git a/ext_emconf.php b/ext_emconf.php index 92748a8..74cb5d1 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -11,8 +11,8 @@ $EM_CONF[$_EXTKEY] = [ 'version' => '1.1.0', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-10.4.99', - 'php' => '7.2.0-7.4.99' + 'typo3' => '10.4.0-11.5.99', + 'php' => '7.2.0-8.1.99' ], ], 'autoload' => [ From 01c8997c1dc593aaed344a44f20c5996d6c11ba6 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Wed, 10 Aug 2022 18:45:33 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20Remove=20unused=20use?= =?UTF-8?q?=20statement=20in=20PageRendererPreProcess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Hooks/PageRendererPreProcess.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Classes/Hooks/PageRendererPreProcess.php b/Classes/Hooks/PageRendererPreProcess.php index 1e1b053..1379a9e 100644 --- a/Classes/Hooks/PageRendererPreProcess.php +++ b/Classes/Hooks/PageRendererPreProcess.php @@ -4,7 +4,6 @@ namespace MMK2410\PlausibleAnalytics\Hooks; use TYPO3\CMS\Core\Page\AssetCollector; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class PageRendererPreProcess { From 9c43bfc8f5fffc2ff46414b2ec47273628f2285d Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Wed, 10 Aug 2022 18:46:22 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20runtime=20crash=20if?= =?UTF-8?q?=20$GLOBALS:=20TSFE=20is=20not=20set=20on=20PHP=208=20and=20hig?= =?UTF-8?q?her?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the case for the backend. Setting it to null yields to an early abortion in the addLibrary function. --- Classes/Hooks/PageRendererPreProcess.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Hooks/PageRendererPreProcess.php b/Classes/Hooks/PageRendererPreProcess.php index 1379a9e..5dc4a0a 100644 --- a/Classes/Hooks/PageRendererPreProcess.php +++ b/Classes/Hooks/PageRendererPreProcess.php @@ -16,7 +16,7 @@ class PageRendererPreProcess public function __construct(AssetCollector $assetCollector = null) { $this->assetCollector = $assetCollector ?? GeneralUtility::makeInstance(AssetCollector::class); - $this->tsfe = $GLOBALS['TSFE']; + $this->tsfe = $GLOBALS['TSFE'] ?? null; } public function addLibrary(): void From 09f9578d20be68abf5134f501705ef157b8468be Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Wed, 10 Aug 2022 18:48:26 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20already=20existi?= =?UTF-8?q?ng=20asset=20collector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason the AssetCollector instance created (or passed) in the PageRendererPreProcess constructor was not used, but instead a new instance was made as part of the addLibrary function. This commit refactors PageRendererPreProcess::addLibrary to use the already created AssetCollector. --- Classes/Hooks/PageRendererPreProcess.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Classes/Hooks/PageRendererPreProcess.php b/Classes/Hooks/PageRendererPreProcess.php index 5dc4a0a..02cf04d 100644 --- a/Classes/Hooks/PageRendererPreProcess.php +++ b/Classes/Hooks/PageRendererPreProcess.php @@ -29,16 +29,15 @@ class PageRendererPreProcess $plausible = $this->getPlausibleURL(); if (isset($domain) && isset($plausible) && !$this->tsfe->isBackendUserLoggedIn()) { - GeneralUtility::makeInstance(AssetCollector::class) - ->addJavaScript( - 'plausible_analytics', - $plausible . '/js/plausible.js', - [ - 'async' => 'async', - 'defer' => 'defer', - 'data-domain' => $domain - ], - ); + $this->assetCollector->addJavaScript( + 'plausible_analytics', + $plausible . '/js/plausible.js', + [ + 'async' => 'async', + 'defer' => 'defer', + 'data-domain' => $domain + ], + ); } }