Merge "Log huge write queries in CLI scripts"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 8 Apr 2015 18:44:45 +0000 (18:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 8 Apr 2015 18:44:45 +0000 (18:44 +0000)
RELEASE-NOTES-1.26
includes/DefaultSettings.php
includes/SiteStats.php
includes/User.php
includes/specials/SpecialActiveusers.php
resources/src/jquery/jquery.suggestions.js
resources/src/mediawiki/mediawiki.searchSuggest.js
tests/phpunit/includes/changes/RecentChangeTest.php

index c65226c..46509be 100644 (file)
@@ -69,7 +69,7 @@ Don't forget to always back up your database before upgrading!
 
 See the file UPGRADE for more detailed upgrade instructions.
 
-For notes on 1.24.x and older releases, see HISTORY.
+For notes on 1.25.x and older releases, see HISTORY.
 
 == Online documentation ==
 
index fa57b8f..dc16ae3 100644 (file)
@@ -1855,13 +1855,6 @@ $wgDBerrorLog = false;
  */
 $wgDBerrorLogTZ = false;
 
-/**
- * Scale load balancer polling time so that under overload conditions, the
- * database server receives a SHOW STATUS query at an average interval of this
- * many microseconds
- */
-$wgDBAvgStatusPoll = 2000;
-
 /**
  * Set to true to engage MySQL 4.1/5.0 charset-related features;
  * for now will just cause sending of 'SET NAMES=utf8' on connect.
index 15c18f3..81172a1 100644 (file)
@@ -68,6 +68,8 @@ class SiteStats {
         * @return bool|ResultWrapper
         */
        static function loadAndLazyInit() {
+               global $wgMiserMode;
+
                wfDebug( __METHOD__ . ": reading site_stats from slave\n" );
                $row = self::doLoad( wfGetDB( DB_SLAVE ) );
 
@@ -77,7 +79,7 @@ class SiteStats {
                        $row = self::doLoad( wfGetDB( DB_MASTER ) );
                }
 
-               if ( !self::isSane( $row ) ) {
+               if ( !$wgMiserMode && !self::isSane( $row ) ) {
                        // Normally the site_stats table is initialized at install time.
                        // Some manual construction scenarios may leave the table empty or
                        // broken, however, for instance when importing from a dump into a
index f23d7dd..f526fe0 100644 (file)
@@ -2202,6 +2202,8 @@ class User implements IDBAccessObject {
         *   page. Ignored if null or !$val.
         */
        public function setNewtalk( $val, $curRev = null ) {
+               global $wgMemc;
+
                if ( wfReadOnly() ) {
                        return;
                }
@@ -2216,7 +2218,6 @@ class User implements IDBAccessObject {
                        $field = 'user_id';
                        $id = $this->getId();
                }
-               global $wgMemc;
 
                if ( $val ) {
                        $changed = $this->updateNewtalk( $field, $id, $curRev );
@@ -2268,37 +2269,13 @@ class User implements IDBAccessObject {
        }
 
        /**
-        * Immediately touch the user data cache for this account.
-        * Updates user_touched field, and removes account data from memcached
-        * for reload on the next hit.
+        * Immediately touch the user data cache for this account
+        *
+        * Calls touch() and removes account data from memcached
         */
        public function invalidateCache() {
-               if ( wfReadOnly() ) {
-                       return;
-               }
-               $this->load();
-               if ( $this->mId ) {
-                       $this->mTouched = $this->newTouchedTimestamp();
-
-                       $dbw = wfGetDB( DB_MASTER );
-                       $userid = $this->mId;
-                       $touched = $this->mTouched;
-                       $method = __METHOD__;
-                       $dbw->onTransactionIdle( function () use ( $dbw, $userid, $touched, $method ) {
-                               // Prevent contention slams by checking user_touched first
-                               $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) );
-                               $needsPurge = $dbw->selectField( 'user', '1',
-                                       array( 'user_id' => $userid, 'user_touched < ' . $encTouched ) );
-                               if ( $needsPurge ) {
-                                       $dbw->update( 'user',
-                                               array( 'user_touched' => $dbw->timestamp( $touched ) ),
-                                               array( 'user_id' => $userid, 'user_touched < ' . $encTouched ),
-                                               $method
-                                       );
-                               }
-                       } );
-                       $this->clearSharedCache();
-               }
+               $this->touch();
+               $this->clearSharedCache();
        }
 
        /**
index a031dad..2c00175 100644 (file)
@@ -302,7 +302,7 @@ class SpecialActiveUsers extends SpecialPage {
         * @return int How many seconds old the cache is
         */
        public static function mergeActiveUsers( $period, $days ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE, 'recentchanges' );
                $cTime = $dbr->selectField( 'querycache_info',
                        'qci_timestamp',
                        array( 'qci_type' => 'activeusers' )
index 813c37c..7c9bec3 100644 (file)
  * @param {Function} options.result.select Called in context of the suggestions-result-current element.
  * @param {jQuery} options.result.select.$textbox
  *
+ * @param {Object} [options.update] Set of callbacks for listening to a change in the text input.
+ *
+ * @param {Function} options.update.before Called right after the user changes the textbox text.
+ * @param {Function} options.update.after Called after results are updated either from the cache or
+ * the API as a result of the user input.
+ *
  * @param {jQuery} [options.$region=this] The element to place the suggestions below and match width of.
  *
  * @param {string[]} [options.suggestions] Array of suggestions to display.
@@ -83,7 +89,7 @@
  * @param {boolean} [options.positionFromLeft] Sets `expandFrom=left`, for backwards
  *  compatibility.
  *
- * @param {boolean} [options.highlightInput=false] Whether to hightlight matched portions of the
+ * @param {boolean} [options.highlightInput=false] Whether to highlight matched portions of the
  *  input or not.
  */
 ( function ( $ ) {
@@ -144,6 +150,10 @@ $.suggestions = {
                                cache = context.data.cache,
                                cacheHit;
 
+                       if ( typeof context.config.update.before === 'function' ) {
+                               context.config.update.before.call( context.data.$textbox );
+                       }
+
                        // Only fetch if the value in the textbox changed and is not empty, or if the results were hidden
                        // if the textbox is empty then clear the result div, but leave other settings intouched
                        if ( val.length === 0 ) {
@@ -158,6 +168,9 @@ $.suggestions = {
                                if ( context.config.cache && hasOwn.call( cache, val ) ) {
                                        if ( +new Date() - cache[ val ].timestamp < context.config.cacheMaxAge ) {
                                                context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions );
+                                               if ( typeof context.config.update.after === 'function' ) {
+                                                       context.config.update.after.call( context.data.$textbox );
+                                               }
                                                cacheHit = true;
                                        } else {
                                                // Cache expired
@@ -171,6 +184,9 @@ $.suggestions = {
                                                function ( suggestions ) {
                                                        suggestions = suggestions.slice( 0, context.config.maxRows );
                                                        context.data.$textbox.suggestions( 'suggestions', suggestions );
+                                                       if ( typeof context.config.update.after === 'function' ) {
+                                                               context.config.update.after.call( context.data.$textbox );
+                                                       }
                                                        if ( context.config.cache ) {
                                                                cache[ val ] = {
                                                                        suggestions: suggestions,
@@ -227,6 +243,7 @@ $.suggestions = {
                        case 'cancel':
                        case 'special':
                        case 'result':
+                       case 'update':
                        case '$region':
                        case 'expandFrom':
                                context.config[property] = value;
@@ -559,6 +576,7 @@ $.fn.suggestions = function () {
                                        cancel: function () {},
                                        special: {},
                                        result: {},
+                                       update: {},
                                        $region: $( this ),
                                        suggestions: [],
                                        maxRows: 10,
index 7b7ccf3..f981b90 100644 (file)
@@ -12,7 +12,8 @@
                        // element (not the search form, as that would leave the buttons
                        // vertically between the input and the suggestions).
                        $searchRegion = $( '#simpleSearch, #searchInput' ).first(),
-                       $searchInput = $( '#searchInput' );
+                       $searchInput = $( '#searchInput' ),
+                       previousSearchText = $searchInput.val();
 
                // Compatibility map
                map = {
                        };
                }
 
+               /**
+                * Callback that's run when the user changes the search input text
+                * 'this' is the search input box (jQuery object)
+                * @ignore
+                */
+               function onBeforeUpdate() {
+                       var searchText = this.val();
+
+                       if ( searchText && searchText !== previousSearchText ) {
+                               mw.track( 'mediawiki.searchSuggest', {
+                                       action: 'session-start'
+                               } );
+                       }
+                       previousSearchText = searchText;
+               }
+
+               /**
+                * Callback that's run when suggestions have been updated either from the cache or the API
+                * 'this' is the search input box (jQuery object)
+                * @ignore
+                */
+               function onAfterUpdate() {
+                       var context = this.data( 'suggestionsContext' );
+
+                       mw.track( 'mediawiki.searchSuggest', {
+                               action: 'impression-results',
+                               numberOfResults: context.config.suggestions.length,
+                               // FIXME: when other types of search become available change this value accordingly
+                               // See the API call below (opensearch = prefix)
+                               resultSetType: 'prefix'
+                       } );
+               }
+
                // The function used to render the suggestions.
                function renderFunction( text, context ) {
                        if ( !resultRenderCache ) {
                                );
                }
 
+               // The function used when the user makes a selection
+               function selectFunction( $input ) {
+                       var context = $input.data( 'suggestionsContext' ),
+                               text = $input.val();
+
+                       mw.track( 'mediawiki.searchSuggest', {
+                               action: 'click-result',
+                               numberOfResults: context.config.suggestions.length,
+                               clickIndex: context.config.suggestions.indexOf( text ) + 1
+                       } );
+
+                       // allow the form to be submitted
+                       return true;
+               }
+
                function specialRenderFunction( query, context ) {
                        var $el = this;
 
                        return;
                }
 
-               // Special suggestions functionality for skin-provided search box
+               // Special suggestions functionality and tracking for skin-provided search box
                $searchInput.suggestions( {
+                       update: {
+                               before: onBeforeUpdate,
+                               after: onAfterUpdate
+                       },
+                       result: {
+                               render: renderFunction,
+                               select: selectFunction
+                       },
                        special: {
                                render: specialRenderFunction,
                                select: function ( $input ) {
index b3cb7b5..0dba183 100644 (file)
@@ -46,6 +46,7 @@ class RecentChangeTest extends MediaWikiTestCase {
         * - protect/protect
         * - protect/modifyprotect
         * - protect/unprotect
+        * - protect/move_prot
         * - upload/upload
         * - merge/merge
         * - import/upload
@@ -223,6 +224,15 @@ class RecentChangeTest extends MediaWikiTestCase {
                        $protectParams,
                        $this->user_comment
                );
+
+               # protect/move_prot
+               $this->assertIRCComment(
+                       $this->context->msg( 'movedarticleprotection', 'SomeTitle', 'OldTitle' )
+                               ->plain() . $sep . $this->user_comment,
+                       'protect', 'move_prot',
+                       array( 'OldTitle' ),
+                       $this->user_comment
+               );
        }
 
        /**