Remove tofu detection logging

Change-Id: I2b808bae2ee19062c16d8aaff2bdf0b2986e8ad0
This commit is contained in:
Amir E. Aharoni
2014-06-26 14:52:15 +03:00
parent 28dcc1e284
commit 6de6bdf8f2
5 changed files with 0 additions and 106 deletions

View File

@@ -82,7 +82,6 @@ $wgResourceModules['ext.uls.eventlogger'] = array(
'dependencies' => array(
'mediawiki.user',
'schema.UniversalLanguageSelector',
'schema.UniversalLanguageSelector-tofu',
),
) + $resourcePaths;

View File

@@ -275,7 +275,6 @@ class UniversalLanguageSelectorHooks {
$wgULSPosition, $wgULSNoWebfontsSelectors,
$wgULSAnonCanChangeLanguage,
$wgULSEventLogging,
$wgULSTofuLoggingChance, $wgULSTofuLoggingMaxTime,
$wgULSImeSelectors, $wgULSNoImeSelectors,
$wgULSFontRepositoryBasePath,
$wgExtensionAssetsPath;
@@ -290,8 +289,6 @@ class UniversalLanguageSelectorHooks {
$vars['wgULSPosition'] = $wgULSPosition;
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
$vars['wgULSEventLogging'] = $wgULSEventLogging;
$vars['wgULSTofuLoggingChance'] = $wgULSTofuLoggingChance;
$vars['wgULSTofuLoggingMaxTime'] = $wgULSTofuLoggingMaxTime;
$vars['wgULSImeSelectors'] = $wgULSImeSelectors;
$vars['wgULSNoImeSelectors'] = $wgULSNoImeSelectors;
$vars['wgULSNoWebfontsSelectors'] = $wgULSNoWebfontsSelectors;

View File

@@ -136,25 +136,6 @@ $GLOBALS['wgULSPosition'] = 'personal';
*/
$GLOBALS['wgULSEventLogging'] = false;
/**
* How frequently to run tofu detection for all languages and to log them.
* This must be a number between 0 and 100, which signifies the percentage
* of pages for which this will be done. If it's 100, then it will be
* done for all pages. If it's 20, then it will be done on 20% of pages.
* The default is not to do it on any pages.
* @since 2014.04
*/
$GLOBALS['wgULSTofuLoggingChance'] = 0;
/**
* If tofu detection for all languages is enabled, and this value is non-zero
* this specifies the maximum time in milliseconds that the tofu detection
* is allowed to run before it's forced to stop.
* The default is 0 - not to force it to stop.
* @since 2014.04
*/
$GLOBALS['wgULSTofuLoggingMaxTime'] = 0;
/**
* Array of jQuery selectors of elements on which IME should be enabled.
*
@@ -261,13 +242,6 @@ $GLOBALS['wgExtensionFunctions'][] = function () {
'schema' => 'UniversalLanguageSelector',
'revision' => 7327441,
);
/// @see https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector-tofu
$wgResourceModules['schema.UniversalLanguageSelector-tofu'] = array(
'class' => 'ResourceLoaderSchemaModule',
'schema' => 'UniversalLanguageSelector-tofu',
'revision' => 7629564,
);
} else {
wfWarn( 'UniversalLanguageSelector is configured to use EventLogging, '
. 'but the extension is not available. Disabling wgULSEventLogging.' );

View File

@@ -42,11 +42,6 @@
interfaceLanguage: mw.config.get( 'wgUserLanguage' )
} );
mw.eventLog.setDefaults( 'UniversalLanguageSelector-tofu', {
version: 1,
token: mw.user.id()
} );
eventLogger.logEventQueue.fire();
},
@@ -92,7 +87,6 @@
mw.hook( 'mw.uls.font.change' ).add( $.proxy( this.fontChange, this ) );
mw.hook( 'mw.uls.webfonts.enable' ).add( $.proxy( this.enableWebfonts, this ) );
mw.hook( 'mw.uls.webfonts.disable' ).add( $.proxy( this.disableWebfonts, this ) );
mw.hook( 'mw.uls.webfonts.tofudetected' ).add( $.proxy( this.tofuDetected, this ) );
$( 'body' ).on( 'noresults.uls', '.uls-menu .languagefilter',
$.proxy( this.noSearchResults, this )
@@ -235,17 +229,6 @@
this.log( { action: 'webfonts-enable', context: context } );
},
/**
* Log tofu detection
* @param {string} language Code of the element in which tofu was detected
*/
tofuDetected: function ( language ) {
this.log( {
tofuElementLanguage: language,
webfontsEnabled: mw.webfonts.preferences.isEnabled()
}, 'UniversalLanguageSelector-tofu' );
},
/**
* Log search strings which produce no search results.
* @param {jQuery.event} event The orignal event

View File

@@ -224,70 +224,11 @@
$( document ).ready( function () {
mw.uls.init( function () {
var tofuStartTime, tofuEndTime, tofuTime;
mw.webfonts.preferences.load();
if ( mw.webfonts.preferences.isEnabled() ) {
mw.loader.using( 'ext.uls.webfonts.fonts', mw.webfonts.setup );
}
// If event logging is enabled and this page "wins" the tofu logging lottery
// try to detect tofu
if ( !mw.config.get( 'wgULSEventLogging' ) ||
mw.config.get( 'wgULSTofuLoggingChance' ) < mw.config.get( 'wgArticleId' ) % 100
) {
return;
}
setTimeout( function () {
var i, lang, text,
$langElements, $element,
maxTime = mw.config.get( 'wgULSTofuLoggingMaxTime' );
tofuStartTime = ( new Date() ).getTime();
// Check all elements that have the lang attribute,
// except the root <html> - it has lang,
// but its text is not useful for testing.
// mw-content-text also always has lang,
// and its text is more relevant.
$langElements = $( 'body [lang]' );
for ( i = 0; i < $langElements.length; i++ ) {
$element = $( $langElements[ i ] );
lang = $element.prop( 'lang' );
// Skip if this languages was already tested
if ( tofuLanguages[lang] !== undefined ) {
continue;
}
text = $.trim( $element.text() ).substr( 0, 4 );
// Skip if the text only has basic ASCII and Latin
if ( !text.match( /[^\u0009-\u0200]/ ) ) {
continue;
}
tofuLanguages[lang] = detectTofu( text );
if ( tofuLanguages[lang] ) {
mw.log( 'tofu detected for ' + lang );
mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( lang );
}
// Force to break the detection loop if it's taking too long
if ( maxTime && ( new Date() ).getTime() - tofuStartTime > maxTime ) {
mw.log( 'tofu detection max time reached. last lang: ' + lang );
break;
}
}
tofuEndTime = ( new Date() ).getTime();
tofuTime = ( tofuEndTime - tofuStartTime ) / 1000;
mw.log( 'tofu detection took ' + tofuTime + ' seconds' );
}, 1000 );
} );
} );
}( jQuery, mediaWiki ) );