Yuvipanda has submitted this change and it was merged.

Change subject: Make EventLogging a soft dependency
......................................................................


Make EventLogging a soft dependency

Based on https://gist.github.com/atdt/4652474

Bug: 61880
Change-Id: Ief5ce7eef43ffe4612541627dff2b0fc75b696ab
---
M Popups.php
M resources/ext.popups.core.js
2 files changed, 34 insertions(+), 23 deletions(-)

Approvals:
  Yuvipanda: Verified; Looks good to me, approved



diff --git a/Popups.php b/Popups.php
index b23f162..5650fa4 100644
--- a/Popups.php
+++ b/Popups.php
@@ -33,8 +33,33 @@
 $localBasePath = dirname( __DIR__ ) . '/Popups';
 $remoteExtPath = 'Popups';
 
-$wgResourceModules = array_merge( $wgResourceModules, array(
-       'ext.popups' => array(
+$wgAutoloadClasses['PopupsHooks'] = __DIR__ . '/Popups.hooks.php';
+$wgExtensionMessagesFiles['Popups'] = __DIR__ . '/Popups.i18n.php';
+
+$wgHooks['GetBetaFeaturePreferences'][] = 'PopupsHooks::getPreferences';
+$wgHooks['BeforePageDisplay'][] = 'PopupsHooks::onBeforePageDisplay';
+
+$wgHooks[ 'ResourceLoaderRegisterModules' ][] = function ( ResourceLoader 
&$resourceLoader ) {
+
+       $moduleDependencies = array(
+               'mediawiki.api',
+               'mediawiki.jqueryMsg',
+               'moment',
+       );
+
+       // If EventLogging is present, declare the schema module
+       // and add it to the array of dependencies.
+       if ( class_exists( 'ResourceLoaderSchemaModule' ) ) {
+               $resourceLoader->register( "schema.Popups", array(
+                       'class'    => 'ResourceLoaderSchemaModule',
+                       'schema'   => 'Popups',
+                       'revision' => 7536956,
+               ) );
+
+               $moduleDependencies[] = "schema.Popups";
+       }
+
+       $resourceLoader->register( "ext.popups", array(
                'scripts' => array(
                        'resources/ext.popups.core.js',
                ),
@@ -42,28 +67,13 @@
                        'resources/ext.popups.core.less',
                        'resources/ext.popups.animation.less',
                ),
-               'dependencies' => array(
-                       'mediawiki.api',
-                       'mediawiki.jqueryMsg',
-                       'moment',
-               ),
+               'dependencies'  => $moduleDependencies,
                'messages' => array(
                        'popups-last-edited',
                        'popups-redirects',
                ),
-               'remoteExtPath' => $remoteExtPath,
-               'localBasePath' => $localBasePath,
-       ),
-
-       'schema.Popups' => array(
-               'class'  => 'ResourceLoaderSchemaModule',
-               'schema' => 'Popups',
-               'revision' => 7536956,
-       ),
-) );
-
-$wgAutoloadClasses['PopupsHooks'] = __DIR__ . '/Popups.hooks.php';
-$wgExtensionMessagesFiles['Popups'] = __DIR__ . '/Popups.i18n.php';
-
-$wgHooks['GetBetaFeaturePreferences'][] = 'PopupsHooks::getPreferences';
-$wgHooks['BeforePageDisplay'][] = 'PopupsHooks::onBeforePageDisplay';
+               'remoteExtPath' => 'Popups',
+               'localBasePath' => dirname( __DIR__ ) . '/Popups',
+       ) );
+       return true;
+};
diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index 2500518..c35ae11 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -355,6 +355,7 @@
                        setTimeout( dfd.reject, 1000 );
                        elTime = elDuration = elAction = undefined;
                }
+               var logEvent = mw.eventLog ? mw.eventLog.logEvent : function () 
{};
 
                /**
                 * @method getSessionId

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ief5ce7eef43ffe4612541627dff2b0fc75b696ab
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to