Merge "Clean up EventLogging integration"

This commit is contained in:
jenkins-bot 2018-08-09 21:54:37 +00:00 committed by Gerrit Code Review
commit 8151b212ee
4 changed files with 28 additions and 39 deletions

View file

@ -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",

View file

@ -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;
}

View file

@ -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 );
}
/**

View file

@ -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.