Amire80 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/142229

Change subject: Remove tofu detection logging
......................................................................

Remove tofu detection logging

Change-Id: I2b808bae2ee19062c16d8aaff2bdf0b2986e8ad0
---
M UniversalLanguageSelector.hooks.php
M UniversalLanguageSelector.php
M resources/js/ext.uls.eventlogger.js
M resources/js/ext.uls.webfonts.js
4 files changed, 0 insertions(+), 98 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/29/142229/1

diff --git a/UniversalLanguageSelector.hooks.php 
b/UniversalLanguageSelector.hooks.php
index 4077484..c826f7f 100644
--- a/UniversalLanguageSelector.hooks.php
+++ b/UniversalLanguageSelector.hooks.php
@@ -275,7 +275,6 @@
                        $wgULSPosition, $wgULSNoWebfontsSelectors,
                        $wgULSAnonCanChangeLanguage,
                        $wgULSEventLogging,
-                       $wgULSTofuLoggingChance, $wgULSTofuLoggingMaxTime,
                        $wgULSImeSelectors, $wgULSNoImeSelectors,
                        $wgULSFontRepositoryBasePath,
                        $wgExtensionAssetsPath;
@@ -290,8 +289,6 @@
                $vars['wgULSPosition'] = $wgULSPosition;
                $vars['wgULSAnonCanChangeLanguage'] = 
$wgULSAnonCanChangeLanguage;
                $vars['wgULSEventLogging'] = $wgULSEventLogging;
-               $vars['wgULSTofuLoggingChance'] = $wgULSTofuLoggingChance;
-               $vars['wgULSTofuLoggingMaxTime'] = $wgULSTofuLoggingMaxTime;
                $vars['wgULSImeSelectors'] = $wgULSImeSelectors;
                $vars['wgULSNoImeSelectors'] = $wgULSNoImeSelectors;
                $vars['wgULSNoWebfontsSelectors'] = $wgULSNoWebfontsSelectors;
diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php
index e4f4974..b8f11a9 100644
--- a/UniversalLanguageSelector.php
+++ b/UniversalLanguageSelector.php
@@ -137,25 +137,6 @@
 $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.
  *
  * @since 2013.11
diff --git a/resources/js/ext.uls.eventlogger.js 
b/resources/js/ext.uls.eventlogger.js
index ced1460..44bfa21 100644
--- a/resources/js/ext.uls.eventlogger.js
+++ b/resources/js/ext.uls.eventlogger.js
@@ -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 )
@@ -233,17 +227,6 @@
                 */
                enableWebfonts: function ( context ) {
                        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' );
                },
 
                /**
diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js
index 0e26cff..9bc30ca 100644
--- a/resources/js/ext.uls.webfonts.js
+++ b/resources/js/ext.uls.webfonts.js
@@ -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 ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b808bae2ee19062c16d8aaff2bdf0b2986e8ad0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>

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

Reply via email to