jenkins-bot has submitted this change and it was merged.

Change subject: Split up $wgEchoConfig
......................................................................


Split up $wgEchoConfig

$wgEchoConfig is a deeply nested structure that ExtensionRegistry can't handle 
well.
It also combined different things, and the version number was used for two
separate purposes.

Split this out into $wgEchoCacheVersion, $wgEchoEventLoggingVersion
and $wgEchoEventLoggingSchemas.

Change-Id: I2f9d5d111f7925fb057d423a3e7064bff5040205
---
M Echo.php
M Hooks.php
M includes/EventLogging.php
M includes/NotifUser.php
M modules/logger/mw.echo.Logger.js
5 files changed, 48 insertions(+), 49 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Echo.php b/Echo.php
index d3ff049..44e4db1 100644
--- a/Echo.php
+++ b/Echo.php
@@ -560,30 +560,31 @@
 $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 0c6717c..0118536 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -10,7 +10,7 @@
         */
        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 @@
 
                // 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 @@
        }
 
        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 @@
         * 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 @@
                );
 
                $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 @@
         * @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 0cceec4..9720bd0 100644
--- a/includes/EventLogging.php
+++ b/includes/EventLogging.php
@@ -14,15 +14,15 @@
         * @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 745c284..cc0a5f4 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -147,8 +147,8 @@
         * 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 @@
         * @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 @@
                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 e5235a4..725c2d0 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'
        );

-- 
To view, visit https://gerrit.wikimedia.org/r/324749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2f9d5d111f7925fb057d423a3e7064bff5040205
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to