Merge "Revert "RCFilters: Change reset button title when it changes state""
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 20 Mar 2017 22:00:30 +0000 (22:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 20 Mar 2017 22:00:30 +0000 (22:00 +0000)
RELEASE-NOTES-1.29
includes/api/ApiQueryAllPages.php
includes/libs/filebackend/FileBackendStore.php
includes/libs/filebackend/SwiftFileBackend.php
includes/specials/SpecialAllPages.php
languages/i18n/en.json
resources/Resources.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js

index 0c483e9..b9a93f1 100644 (file)
@@ -80,6 +80,7 @@ production.
 * (T27187) Search suggestions based on jquery.suggestions will now correctly only
   highlight prefix matches in the results.
 * (T157035) "new mw.Uri()" was ignoring options when using default URI.
+* Special:Allpages can no longer be filtered by redirect in miser mode.
 
 === Action API changes in 1.29 ===
 * Submitting sensitive authentication request parameters to action=login,
@@ -114,6 +115,9 @@ production.
 * action=purge now requires a POST.
 * There is a new `languagevariants` siprop for action=query&meta=siteinfo,
   which returns a list of languages with active LanguageConverter instances.
+* action=query&query=allpages will no longer filter redirects using a database
+  query in miser mode. This may result in less results being returned than were
+  requested.
 
 === Action API internal changes in 1.29 ===
 * New methods were added to ApiBase to handle errors and warnings using i18n
index 7460bd5..6b959ae 100644 (file)
@@ -76,10 +76,13 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                        $this->addWhere( "page_title $op= $cont_from" );
                }
 
-               if ( $params['filterredir'] == 'redirects' ) {
-                       $this->addWhereFld( 'page_is_redirect', 1 );
-               } elseif ( $params['filterredir'] == 'nonredirects' ) {
-                       $this->addWhereFld( 'page_is_redirect', 0 );
+               $miserMode = $this->getConfig()->get( 'MiserMode' );
+               if ( !$miserMode ) {
+                       if ( $params['filterredir'] == 'redirects' ) {
+                               $this->addWhereFld( 'page_is_redirect', 1 );
+                       } elseif ( $params['filterredir'] == 'nonredirects' ) {
+                               $this->addWhereFld( 'page_is_redirect', 0 );
+                       }
                }
 
                $this->addWhereFld( 'page_namespace', $params['namespace'] );
@@ -108,6 +111,18 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                        $selectFields = $resultPageSet->getPageTableFields();
                }
 
+               $miserModeFilterRedirValue = null;
+               $miserModeFilterRedir = $miserMode && $params['filterredir'] !== 'all';
+               if ( $miserModeFilterRedir ) {
+                       $selectFields[] = 'page_is_redirect';
+
+                       if ( $params['filterredir'] == 'redirects' ) {
+                               $miserModeFilterRedirValue = 1;
+                       } elseif ( $params['filterredir'] == 'nonredirects' ) {
+                               $miserModeFilterRedirValue = 0;
+                       }
+               }
+
                $this->addFields( $selectFields );
                $forceNameTitleIndex = true;
                if ( isset( $params['minsize'] ) ) {
@@ -219,6 +234,11 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                                break;
                        }
 
+                       if ( $miserModeFilterRedir && (int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
+                               // Filter implemented in PHP due to being in Miser Mode
+                               continue;
+                       }
+
                        if ( is_null( $resultPageSet ) ) {
                                $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                                $vals = [
@@ -242,7 +262,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
-               return [
+               $ret = [
                        'from' => null,
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
@@ -314,6 +334,12 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_DFLT => 'all'
                        ],
                ];
+
+               if ( $this->getConfig()->get( 'MiserMode' ) ) {
+                       $ret['filterredir'][ApiBase::PARAM_HELP_MSG_APPEND] = [ 'api-help-param-limited-in-miser-mode' ];
+               }
+
+               return $ret;
        }
 
        protected function getExamplesMessages() {
index 7cb26c6..039bd42 100644 (file)
@@ -1200,21 +1200,20 @@ abstract class FileBackendStore extends FileBackend {
         * to the order in which the handles where given.
         *
         * @param FileBackendStoreOpHandle[] $fileOpHandles
-        *
-        * @throws FileBackendError
         * @return StatusValue[] Map of StatusValue objects
+        * @throws FileBackendError
         */
        final public function executeOpHandlesInternal( array $fileOpHandles ) {
                $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
 
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
-                               throw new InvalidArgumentException( "Got a non-FileBackendStoreOpHandle object." );
+                               throw new InvalidArgumentException( "Expected FileBackendStoreOpHandle object." );
                        } elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) {
-                               throw new InvalidArgumentException(
-                                       "Got a FileBackendStoreOpHandle for the wrong backend." );
+                               throw new InvalidArgumentException( "Expected handle for this file backend." );
                        }
                }
+
                $res = $this->doExecuteOpHandlesInternal( $fileOpHandles );
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        $fileOpHandle->closeResources();
index 631f6fd..ae0ad6f 100644 (file)
@@ -287,7 +287,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -353,7 +353,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -401,7 +401,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -460,7 +460,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually move the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -500,7 +500,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually delete the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -556,7 +556,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually change the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
index 4b8446a..fd7bc3f 100644 (file)
@@ -69,7 +69,11 @@ class SpecialAllPages extends IncludableSpecialPage {
                $from = $request->getVal( 'from', null );
                $to = $request->getVal( 'to', null );
                $namespace = $request->getInt( 'namespace' );
-               $hideredirects = $request->getBool( 'hideredirects', false );
+
+               $miserMode = (bool)$this->getConfig()->get( 'MiserMode' );
+
+               // Redirects filter is disabled in MiserMode
+               $hideredirects = $request->getBool( 'hideredirects', false ) && !$miserMode;
 
                $namespaces = $this->getLanguage()->getNamespaces();
 
@@ -100,6 +104,7 @@ class SpecialAllPages extends IncludableSpecialPage {
        protected function outputHTMLForm( $namespace = NS_MAIN,
                $from = '', $to = '', $hideRedirects = false
        ) {
+               $miserMode = (bool)$this->getConfig()->get( 'MiserMode' );
                $fields = [
                        'from' => [
                                'type' => 'text',
@@ -133,6 +138,11 @@ class SpecialAllPages extends IncludableSpecialPage {
                                'value' => $hideRedirects,
                        ],
                ];
+
+               if ( $miserMode ) {
+                       unset ( $fields['hideredirects'] );
+               }
+
                $form = HTMLForm::factory( 'table', $fields, $this->getContext() );
                $form->setMethod( 'get' )
                        ->setWrapperLegendMsg( 'allpages' )
index ccfa91b..eb43cdb 100644 (file)
        "page_first": "first",
        "page_last": "last",
        "histlegend": "Diff selection: Mark the radio boxes of the revisions to compare and hit enter or the button at the bottom.<br />\nLegend: <strong>({{int:cur}})</strong> = difference with latest revision, <strong>({{int:last}})</strong> = difference with preceding revision, <strong>{{int:minoreditletter}}</strong> = minor edit.",
-       "history-fieldset-title": "Browse history",
+       "history-fieldset-title": "Search for revisions",
        "history-show-deleted": "Revision deleted only",
        "history_copyright": "-",
        "histfirst": "oldest",
        "recentchanges-legend": "Recent changes options",
        "recentchanges-summary": "Track the most recent changes to the wiki on this page.",
        "recentchangestext": "-",
-       "recentchanges-noresult": "No changes during the given period matching these criteria.",
+       "recentchanges-noresult": "No changes during the given period match these criteria.",
        "recentchanges-feed-description": "Track the most recent changes to the wiki in this feed.",
        "recentchanges-label-newpage": "This edit created a new page",
        "recentchanges-label-minor": "This is a minor edit",
index 392cdb3..4ce326d 100644 (file)
@@ -2253,7 +2253,7 @@ return [
                        'mediawiki.api',
                        'jquery.byteLimit',
                        // TitleOptionWidget
-                       'jquery.autoEllipsis',
+                       'jquery.highlightText',
                ],
                'messages' => [
                        // NamespaceInputWidget
index 44c7bf0..e034826 100644 (file)
         * Empty all selected filters
         */
        mw.rcfilters.Controller.prototype.emptyFilters = function () {
+               var highlightedFilterNames = this.filtersModel
+                       .getHighlightedItems()
+                       .map( function ( filterItem ) { return { name: filterItem.getName() }; } );
+
                this.filtersModel.emptyAllFilters();
                this.filtersModel.clearAllHighlightColors();
                // Check all filter interactions
                this.filtersModel.reassessFilterInteractions();
 
                this.updateChangesList();
+
+               if ( highlightedFilterNames ) {
+                       this.trackHighlight( 'clearAll', highlightedFilterNames );
+               }
        };
 
        /**
        mw.rcfilters.Controller.prototype.setHighlightColor = function ( filterName, color ) {
                this.filtersModel.setHighlightColor( filterName, color );
                this.updateURL();
+               this.trackHighlight( 'set', { name: filterName, color: color } );
        };
 
        /**
        mw.rcfilters.Controller.prototype.clearHighlightColor = function ( filterName ) {
                this.filtersModel.clearHighlightColor( filterName );
                this.updateURL();
+               this.trackHighlight( 'clear', filterName );
        };
 
        /**
         * @param {string} filterName Name of the filter item
         */
        mw.rcfilters.Controller.prototype.clearFilter = function ( filterName ) {
-               var filterItem = this.filtersModel.getItemByName( filterName );
+               var filterItem = this.filtersModel.getItemByName( filterName ),
+                       isHighlighted = filterItem.isHighlighted();
 
-               if ( filterItem.isSelected() || filterItem.isHighlighted() ) {
+               if ( filterItem.isSelected() || isHighlighted ) {
                        this.filtersModel.clearHighlightColor( filterName );
                        this.filtersModel.toggleFilterSelected( filterName, false );
                        this.updateChangesList();
                        this.filtersModel.reassessFilterInteractions( filterItem );
                }
+
+               if ( isHighlighted ) {
+                       this.trackHighlight( 'clear', filterName );
+               }
        };
 
        /**
                        this.getUpdatedUri().toString()
                );
        };
+
+       /**
+        * Track usage of highlight feature
+        *
+        * @param {string} action
+        * @param {array|object|string} filters
+        */
+       mw.rcfilters.Controller.prototype.trackHighlight = function ( action, filters ) {
+               filters = $.type( filters ) === 'string' ? { name: filters } : filters;
+               filters = $.type( filters ) === 'object' ? [ filters ] : filters;
+               mw.track(
+                       'event.ChangesListHighlights',
+                       {
+                               action: action,
+                               filters: filters
+                       }
+               );
+       };
 }( mediaWiki, jQuery ) );
index e64a4c0..1fba18c 100644 (file)
                        }
                } else {
                        this.scrollToTop( this.capsule.$element, 10 );
+                       if ( !this.filterPopup.getSelectedFilter() ) {
+                               // No selection, scroll the popup list to top
+                               setTimeout( function () { this.capsule.popup.$body.scrollTop( 0 ); }.bind( this ), 0 );
+                       }
                }
        };
 
index 37e6e1a..3583e5e 100644 (file)
@@ -65,7 +65,9 @@
                } );
 
                // Highlight matching parts of link suggestion
-               this.$label.autoEllipsis( { hasSpan: false, tooltip: true, matchText: config.query } );
+               this.$label
+                       .highlightText( config.query )
+                       .attr( 'title', config.data );
 
                if ( config.missing ) {
                        this.$label.addClass( 'new' );