diff --git a/extension.json b/extension.json index abec3fe7f..7003702b6 100644 --- a/extension.json +++ b/extension.json @@ -422,7 +422,6 @@ "BeforePageDisplay": "EchoHooks::beforePageDisplay", "MakeGlobalVariablesScript": "EchoHooks::makeGlobalVariablesScript", "ResourceLoaderRegisterModules": "EchoHooks::onResourceLoaderRegisterModules", - "EventLoggingRegisterSchemas": "EchoHooks::onEventLoggingRegisterSchemas", "ResourceLoaderTestModules": "EchoHooks::onResourceLoaderTestModules", "UserGroupsChanged": "EchoHooks::onUserGroupsChanged", "UserLoadOptions": "EchoHooks::onUserLoadOptions", @@ -886,19 +885,13 @@ "EchoEventLoggingSchemas": { "value": { "Echo": { - "enabled": false, - "revision": 7731316, - "client": false + "enabled": false }, "EchoMail": { - "enabled": false, - "revision": 5467650, - "client": false + "enabled": false }, "EchoInteraction": { - "enabled": false, - "revision": 15823738, - "client": true + "enabled": false } }, "merge_strategy": "array_plus_2d" @@ -912,6 +905,13 @@ "description": "Maximum nubmer of users that will be notified that they were linked from an edit summary or 0 for no notifications" } }, + "attributes": { + "EventLogging": { + "Schemas": { + "EchoInteraction": 15823738 + } + } + }, "manifest_version": 2, "AutoloadClasses": { "ApiCrossWikiBase": "includes/api/ApiCrossWikiBase.php", diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index 76f91ab7e..988e7917f 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -50,7 +50,7 @@ class EchoHooks { */ public static function initEchoExtension() { global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons, - $wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification, $wgAPIModules; + $wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification, $wgAPIModules; // allow extensions to define their own event Hooks::run( 'BeforeCreateEchoEvent', [ &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ] ); @@ -66,15 +66,6 @@ class EchoHooks { unset( $wgEchoNotificationCategories['article-reminder'] ); unset( $wgAPIModules['echoarticlereminder'] ); } - - // turn schema off if eventLogging is not enabled - if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) { - foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { - if ( $property['enabled'] ) { - $wgEchoEventLoggingSchemas[$schema]['enabled'] = false; - } - } - } } public static function getNotificationSenderName() { @@ -129,15 +120,6 @@ class EchoHooks { return true; } - public static function onEventLoggingRegisterSchemas( array &$schemas ) { - global $wgEchoEventLoggingSchemas; - foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { - if ( $property['enabled'] && $property['client'] ) { - $schemas[$schema] = $property['revision']; - } - } - } - /** * Handler for ResourceLoaderRegisterModules hook * @param ResourceLoader &$resourceLoader @@ -1090,10 +1072,10 @@ class EchoHooks { global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion; $user = $outputPage->getUser(); - // Provide info for the Overlay - + // Provide info for ext.echo.logger if ( $user->isLoggedIn() ) { - $vars['wgEchoEventLoggingSchemas'] = $wgEchoEventLoggingSchemas; + $vars['wgEchoInteractionLogging'] = $wgEchoEventLoggingSchemas['EchoInteraction']['enabled'] + && ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ); $vars['wgEchoEventLoggingVersion'] = $wgEchoEventLoggingVersion; } diff --git a/includes/EventLogging.php b/includes/EventLogging.php index c7f0ba52b..9ffba03ac 100644 --- a/includes/EventLogging.php +++ b/includes/EventLogging.php @@ -5,6 +5,14 @@ */ class MWEchoEventLogging { + private static $revisionIds = [ + 'Echo' => 7731316, + 'EchoMail' => 5467650, + // Keep in sync with client-side revision + // in extension.json + 'EchoInteraction' => 15823738 + ]; + /** * This is the only function that interacts with EventLogging * @@ -17,14 +25,17 @@ class MWEchoEventLogging { global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion; $schemaConfig = $wgEchoEventLoggingSchemas[$schema]; - if ( !$schemaConfig['enabled'] ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) + || !$schemaConfig['enabled'] + ) { // If logging for this schema is disabled, it's a no-op. return; } + $revision = self::$revisionIds[$schema]; $data['version'] = $wgEchoEventLoggingVersion; - EventLogging::logEvent( $schema, $schemaConfig['revision'], $data ); + EventLogging::logEvent( $schema, $revision, $data ); } /** diff --git a/modules/logger/mw.echo.Logger.js b/modules/logger/mw.echo.Logger.js index 1a920c57b..cf380bbb7 100644 --- a/modules/logger/mw.echo.Logger.js +++ b/modules/logger/mw.echo.Logger.js @@ -28,11 +28,7 @@ * @static * @property {boolean} */ - mw.echo.Logger.static.clickThroughEnabled = !!OO.getProp( - mw.config.get( 'wgEchoEventLoggingSchemas' ), - 'EchoInteraction', - 'enabled' - ); + mw.echo.Logger.static.clickThroughEnabled = !!mw.config.get( 'wgEchoInteractionLogging' ); /** * Context definitions.