mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-09-23 10:22:05 +00:00
Clean up EventLogging integration
* Move revision ids out of configuration and into MWEchoEventLogging class. Because the EchoInteraction schema is used both server and client, we have to duplicate the revision id. * Use EventLoggingSchemas attribute to register client-side schema in extension.json instead of a hook. * Check if EventLogging is enabled in MWEchoEventLogging instead of $wgExtensionFunctions. * Pass only whether the EchoInteraction schema is enabled to the client-side instead of all of $wgEchoEventLoggingSchemas. Change-Id: I968294f96cedac19dc9d8f53df14fecfb666ceee
This commit is contained in:
parent
832d9d4d16
commit
b574e252f8
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue