diff --git a/CHANGELOG.md b/CHANGELOG.md index dea52e5..02479c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## ChangeLog for MatomoAnalytics +### 1.1.1 (29-01-2023) +* Don't override $text within MatomoAnalyticsHooks::matomoScript + ### 1.1.0 (29-01-2023) * Ensure matomo script isn't added more than once * Change error to warning for "could not find db in matomo table" logging diff --git a/extension.json b/extension.json index 246555f..eaa92cd 100644 --- a/extension.json +++ b/extension.json @@ -6,7 +6,7 @@ "Universal Omega" ], "url": "https://github.com/miraheze/MatomoAnalytics", - "version": "1.1.0", + "version": "1.1.1", "descriptionmsg": "matomoanalytics-desc", "license-name": "GPL-3.0-or-later", "type": "specialpage", diff --git a/includes/MatomoAnalyticsHooks.php b/includes/MatomoAnalyticsHooks.php index 04ef98a..d14d836 100644 --- a/includes/MatomoAnalyticsHooks.php +++ b/includes/MatomoAnalyticsHooks.php @@ -32,13 +32,11 @@ public static function wikiRename( $dbw, $old, $new ) { * @param string &$text Output text. * @return bool */ - public static function matomoScript( $skin, &$text = '' ) { + public static function matomoScript( $skin, &$text ) { $config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'matomoanalytics' ); - static $alreadyDone = false; - - // Check if JS tracking is disabled or if the script has already been added and bow out early - if ( $alreadyDone || $config->get( 'MatomoAnalyticsDisableJS' ) ) { + // Check if JS tracking is disabled and bow out early + if ( $config->get( 'MatomoAnalyticsDisableJS' ) === true ) { return true; } @@ -47,49 +45,48 @@ public static function matomoScript( $skin, &$text = '' ) { $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); if ( $permissionManager->userHasRight( $user, 'noanalytics' ) ) { - $text .= ''; - } else { - $id = strval( $mAId ); - $globalId = (string)$config->get( 'MatomoAnalyticsGlobalID' ); - $globalIdInt = (int)$globalId; - $serverurl = $config->get( 'MatomoAnalyticsServerURL' ); - $title = $skin->getRelevantTitle(); - - $jstitle = Xml::encodeJsVar( $title->getPrefixedText() ); - $dbname = Xml::encodeJsVar( $config->get( 'DBname' ) ); - $urltitle = $title->getPrefixedURL(); - $userType = $user->isRegistered() ? 'User' : 'Anonymous'; - $cookieDisable = (int)$config->get( 'MatomoAnalyticsDisableCookie' ); - $forceGetRequest = (int)$config->get( 'MatomoAnalyticsForceGetRequest' ); - $text .= << - - SCRIPT; + $text = ''; + return true; } - $alreadyDone = true; + $id = strval( $mAId ); + $globalId = (string)$config->get( 'MatomoAnalyticsGlobalID' ); + $globalIdInt = (int)$globalId; + $serverurl = $config->get( 'MatomoAnalyticsServerURL' ); + $title = $skin->getRelevantTitle(); + + $jstitle = Xml::encodeJsVar( $title->getPrefixedText() ); + $dbname = Xml::encodeJsVar( $config->get( 'DBname' ) ); + $urltitle = $title->getPrefixedURL(); + $userType = $user->isRegistered() ? 'User' : 'Anonymous'; + $cookieDisable = (int)$config->get( 'MatomoAnalyticsDisableCookie' ); + $forceGetRequest = (int)$config->get( 'MatomoAnalyticsForceGetRequest' ); + $text = << + + SCRIPT; return true; }