diff --git a/Echo.php b/Echo.php index d3ff049d6..44e4db159 100644 --- a/Echo.php +++ b/Echo.php @@ -560,30 +560,31 @@ $wgDefaultUserOptions['echo-subscriptions-web-article-linked'] = false; $wgDefaultUserOptions['echo-subscriptions-web-mention-failure'] = false; $wgDefaultUserOptions['echo-subscriptions-web-mention-success'] = false; +// Echo cache version +$wgEchoCacheVersion = '1.12'; + // Echo Configuration for EventLogging -$wgEchoConfig = array( - 'version' => '1.12', - 'eventlogging' => array( - /** - * Properties: - * - 'enabled': Whether it should be used - * - 'revision': revision id of the schema - * - 'client': whether the schema is needed client-side - */ - 'Echo' => array( - 'enabled' => false, - 'revision' => 7731316, - 'client' => false, - ), - 'EchoMail' => array( - 'enabled' => false, - 'revision' => 5467650, - 'client' => false, - ), - 'EchoInteraction' => array( - 'enabled' => false, - 'revision' => 15823738, - 'client' => true, - ), - ) +$wgEchoEventLoggingVersion = '1.12'; +$wgEchoEventLoggingSchemas = array( + /** + * Properties: + * - 'enabled': Whether it should be used + * - 'revision': revision id of the schema + * - 'client': whether the schema is needed client-side + */ + 'Echo' => array( + 'enabled' => false, + 'revision' => 7731316, + 'client' => false, + ), + 'EchoMail' => array( + 'enabled' => false, + 'revision' => 5467650, + 'client' => false, + ), + 'EchoInteraction' => array( + 'enabled' => false, + 'revision' => 15823738, + 'client' => true, + ), ); diff --git a/Hooks.php b/Hooks.php index 0c6717c94..0118536dd 100644 --- a/Hooks.php +++ b/Hooks.php @@ -10,7 +10,7 @@ class EchoHooks { */ public static function initEchoExtension() { global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons, - $wgEchoConfig, $wgEchoMentionStatusNotifications; + $wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications; // allow extensions to define their own event Hooks::run( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ) ); @@ -23,9 +23,9 @@ class EchoHooks { // turn schema off if eventLogging is not enabled if ( !class_exists( 'EventLogging' ) ) { - foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) { + foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { if ( $property['enabled'] ) { - $wgEchoConfig['eventlogging'][$schema]['enabled'] = false; + $wgEchoEventLoggingSchemas[$schema]['enabled'] = false; } } } @@ -84,8 +84,8 @@ class EchoHooks { } public static function onEventLoggingRegisterSchemas( array &$schemas ) { - global $wgEchoConfig; - foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) { + global $wgEchoEventLoggingSchemas; + foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { if ( $property['enabled'] && $property['client'] ) { $schemas[$schema] = $property['revision']; } @@ -96,7 +96,7 @@ class EchoHooks { * Handler for ResourceLoaderRegisterModules hook */ public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) { - global $wgEchoConfig; + global $wgEchoEventLoggingSchemas; // ext.echo.logger is used by mobile notifications as well, so be sure not to add any // dependencies that do not target mobile. @@ -114,7 +114,7 @@ class EchoHooks { ); $hasSchemas = false; - foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) { + foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { if ( $property['enabled'] && $property['client'] ) { $definition['dependencies'][] = 'schema.' . $schema; $hasSchemas = true; @@ -1022,23 +1022,22 @@ class EchoHooks { * @return bool true in all cases */ public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) { - global $wgEchoConfig; + global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion; $user = $outputPage->getUser(); // Provide info for the Overlay if ( $user->isLoggedIn() ) { - $vars['wgEchoConfig'] = $wgEchoConfig; + $vars['wgEchoEventLoggingSchemas'] = $wgEchoEventLoggingSchemas; + $vars['wgEchoEventLoggingVersion'] = $wgEchoEventLoggingVersion; } elseif ( $outputPage->getTitle()->equals( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) ) || // Also if running from /plain or /export $outputPage->getTitle()->isSubpageOf( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) ) ) { // For testing purposes - $vars['wgEchoConfig'] = array( - 'eventlogging' => array( - 'EchoInteraction' => array(), - ), + $vars['wgEchoEventLoggingSchemas'] = array( + 'EchoInteraction' => array(), ); } diff --git a/includes/EventLogging.php b/includes/EventLogging.php index 0cceec420..9720bd072 100644 --- a/includes/EventLogging.php +++ b/includes/EventLogging.php @@ -14,15 +14,15 @@ class MWEchoEventLogging { * @param array $data */ protected static function logEvent( $schema, array $data ) { - global $wgEchoConfig; + global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion; - $schemaConfig = $wgEchoConfig['eventlogging'][$schema]; + $schemaConfig = $wgEchoEventLoggingSchemas[$schema]; if ( !$schemaConfig['enabled'] ) { // If logging for this schema is disabled, it's a no-op. return; } - $data['version'] = $wgEchoConfig['version']; + $data['version'] = $wgEchoEventLoggingVersion; EventLogging::logEvent( $schema, $schemaConfig['revision'], $data ); } diff --git a/includes/NotifUser.php b/includes/NotifUser.php index 745c28466..cc0a5f437 100644 --- a/includes/NotifUser.php +++ b/includes/NotifUser.php @@ -147,8 +147,8 @@ class MWEchoNotifUser { * Memcache key for talk notification */ public function getTalkNotificationCacheKey() { - global $wgEchoConfig; - return wfMemcKey( 'echo-new-talk-notification', $this->mUser->getId(), $wgEchoConfig['version'] ); + global $wgEchoCacheVersion; + return wfMemcKey( 'echo-new-talk-notification', $this->mUser->getId(), $wgEchoCacheVersion ); } /** @@ -654,9 +654,9 @@ class MWEchoNotifUser { * @return string|false Memcached key, or false if one could not be generated */ protected function getMemcKey( $key, $global = false ) { - global $wgEchoConfig; + global $wgEchoCacheVersion; if ( !$global ) { - return wfMemcKey( $key, $this->mUser->getId(), $wgEchoConfig['version'] ); + return wfMemcKey( $key, $this->mUser->getId(), $wgEchoCacheVersion ); } $lookup = CentralIdLookup::factory(); @@ -664,7 +664,7 @@ class MWEchoNotifUser { if ( !$globalId ) { return false; } - return wfGlobalCacheKey( $key, $globalId, $wgEchoConfig['version'] ); + return wfGlobalCacheKey( $key, $globalId, $wgEchoCacheVersion ); } diff --git a/modules/logger/mw.echo.Logger.js b/modules/logger/mw.echo.Logger.js index e5235a40a..725c2d036 100644 --- a/modules/logger/mw.echo.Logger.js +++ b/modules/logger/mw.echo.Logger.js @@ -19,7 +19,7 @@ // This should usually already be loaded, but not always this.deferred = mw.loader.using( 'ext.eventLogging', function () { mw.eventLog.setDefaults( 'EchoInteraction', { - version: mw.config.get( 'wgEchoConfig' ).version, + version: mw.config.get( 'wgEchoEventLoggingVersion' ), userId: +mw.config.get( 'wgUserId' ), editCount: +mw.config.get( 'wgUserEditCount' ) } ); @@ -41,8 +41,7 @@ * @property {boolean} */ mw.echo.Logger.static.clickThroughEnabled = OO.getProp( - mw.config.get( 'wgEchoConfig' ), - 'eventlogging', + mw.config.get( 'wgEchoEventLoggingSchemas' ), 'EchoInteraction', 'enabled' );