Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/72614
Change subject: Use 'mw.hook' to queue events until EL has loaded
......................................................................
Use 'mw.hook' to queue events until EL has loaded
This patch provides a workaround for bug 50746. It modifies mw.uls.eventLog so
that it does not directly attempt to log events but instead adds them to a
callback queue that is deferred until a 'uls.eventLoggingSchemaLoaded' hook
fires. If EventLogging is not enabled, the hook never fires. If EventLogging is
enabled, it is requested via mw.loader.using, but only after $(document).ready.
This prevents ResourceLoader from attempting to inject it via document.write.
The mw.loader.using callback sets the schema defaults and fires
'uls.eventLoggingSchemaLoaded', causing the EventLogging event queue to be
processed. Tested on Opera 12 and Chrome 30 on OS X.
Bug: 50746
Change-Id: I89cf06990ee85e70698149b4812d7900218e4fb4
---
M resources/js/ext.uls.init.js
1 file changed, 19 insertions(+), 17 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector
refs/changes/14/72614/1
diff --git a/resources/js/ext.uls.init.js b/resources/js/ext.uls.init.js
index 0242184..64cff75 100644
--- a/resources/js/ext.uls.init.js
+++ b/resources/js/ext.uls.init.js
@@ -156,24 +156,11 @@
* @since 2013.07
* @see https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector
*/
- mw.uls.logEvent = $.noop;
-
- // If EventLogging integration is enabled, set event defaults and make
the
- // the function call event logging with correct schema.
- if ( mw.config.get( 'wgULSEventLogging' ) ) {
- mw.loader.using( 'schema.UniversalLanguageSelector', function
() {
- mw.eventLog.setDefaults( 'UniversalLanguageSelector', {
- version: 1,
- token: mw.user.id(),
- contentLanguage: mw.config.get(
'wgContentLanguage' ),
- interfaceLanguage: currentLang
- } );
-
- mw.uls.logEvent = function ( event ) {
- mw.eventLog.logEvent(
'UniversalLanguageSelector', event );
- };
+ mw.uls.logEvent = function ( event ) {
+ mw.hook( 'uls.eventLoggingSchemaLoaded' ).add( function () {
+ mw.eventLog.logEvent( 'UniversalLanguageSelector',
event );
} );
- }
+ };
/**
* jquery.i18n message store for MediaWiki
@@ -239,6 +226,21 @@
return;
}
+ // If EventLogging integration is enabled, set event defaults
and make the
+ // the function call event logging with correct schema.
+ if ( mw.config.get( 'wgULSEventLogging' ) ) {
+ mw.loader.using( 'schema.UniversalLanguageSelector',
function () {
+ mw.eventLog.setDefaults(
'UniversalLanguageSelector', {
+ version: 1,
+ token: mw.user.id(),
+ contentLanguage: mw.config.get(
'wgContentLanguage' ),
+ interfaceLanguage: currentLang
+ } );
+ mw.hook( 'uls.eventLoggingSchemaLoaded'
).fire();
+ } );
+ }
+
+
/*
* The 'als' is used in a non-standard way in MediaWiki -
* it may be used to represent the Allemanic language,
--
To view, visit https://gerrit.wikimedia.org/r/72614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I89cf06990ee85e70698149b4812d7900218e4fb4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits