Merge "Improve test coverage for ApiParse"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 12 Apr 2018 16:27:03 +0000 (16:27 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 12 Apr 2018 16:27:03 +0000 (16:27 +0000)
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php
languages/i18n/en.json
languages/i18n/qqq.json
mw-config/config.css
resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
tests/parser/ParserTestRunner.php
tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php

index eb2cada..2a4acc8 100644 (file)
@@ -87,9 +87,12 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
        // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
        // that is registered conditionally.
+       private $legacyReviewStatusFilterGroupDefinition;
+
+       // Single filter group registered conditionally
        private $reviewStatusFilterGroupDefinition;
 
-       // Single filter registered conditionally
+       // Single filter group registered conditionally
        private $hideCategorizationFilterDefinition;
 
        /**
@@ -301,7 +304,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                ]
                        ],
 
-                       // reviewStatus (conditional)
+                       // significance (conditional)
 
                        [
                                'name' => 'significance',
@@ -457,17 +460,14 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
                ];
 
-               $this->reviewStatusFilterGroupDefinition = [
+               $this->legacyReviewStatusFilterGroupDefinition = [
                        [
-                               'name' => 'reviewStatus',
+                               'name' => 'legacyReviewStatus',
                                'title' => 'rcfilters-filtergroup-reviewstatus',
                                'class' => ChangesListBooleanFilterGroup::class,
-                               'priority' => -5,
                                'filters' => [
                                        [
                                                'name' => 'hidepatrolled',
-                                               'label' => 'rcfilters-filter-patrolled-label',
-                                               'description' => 'rcfilters-filter-patrolled-description',
                                                // rcshowhidepatr-show, rcshowhidepatr-hide
                                                // wlshowhidepatr
                                                'showHideSuffix' => 'showhidepatr',
@@ -477,27 +477,75 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                                ) {
                                                        $conds[] = 'rc_patrolled = 0';
                                                },
-                                               'cssClassSuffix' => 'patrolled',
-                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
-                                                       return $rc->getAttribute( 'rc_patrolled' );
-                                               },
+                                               'isReplacedInStructuredUi' => true,
                                        ],
                                        [
                                                'name' => 'hideunpatrolled',
-                                               'label' => 'rcfilters-filter-unpatrolled-label',
-                                               'description' => 'rcfilters-filter-unpatrolled-description',
                                                'default' => false,
                                                'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
                                                        &$query_options, &$join_conds
                                                ) {
                                                        $conds[] = 'rc_patrolled != 0';
                                                },
-                                               'cssClassSuffix' => 'unpatrolled',
+                                               'isReplacedInStructuredUi' => true,
+                                       ],
+                               ],
+                       ]
+               ];
+
+               $this->reviewStatusFilterGroupDefinition = [
+                       [
+                               'name' => 'reviewStatus',
+                               'title' => 'rcfilters-filtergroup-reviewstatus',
+                               'class' => ChangesListStringOptionsFilterGroup::class,
+                               'isFullCoverage' => true,
+                               'priority' => -5,
+                               'filters' => [
+                                       [
+                                               'name' => 'unpatrolled',
+                                               'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
+                                               'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
+                                               'cssClassSuffix' => 'reviewstatus-unpatrolled',
+                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                                       return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
+                                               },
+                                       ],
+                                       [
+                                               'name' => 'manual',
+                                               'label' => 'rcfilters-filter-reviewstatus-manual-label',
+                                               'description' => 'rcfilters-filter-reviewstatus-manual-description',
+                                               'cssClassSuffix' => 'reviewstatus-manual',
                                                'isRowApplicableCallable' => function ( $ctx, $rc ) {
-                                                       return !$rc->getAttribute( 'rc_patrolled' );
+                                                       return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
+                                               },
+                                       ],
+                                       [
+                                               'name' => 'auto',
+                                               'label' => 'rcfilters-filter-reviewstatus-auto-label',
+                                               'description' => 'rcfilters-filter-reviewstatus-auto-description',
+                                               'cssClassSuffix' => 'reviewstatus-auto',
+                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                                       return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
                                                },
                                        ],
                                ],
+                               'default' => ChangesListStringOptionsFilterGroup::NONE,
+                               'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
+                                       &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
+                               ) {
+                                       if ( $selected === [] ) {
+                                               return;
+                                       }
+                                       $rcPatrolledValues = [
+                                               'unpatrolled' => RecentChange::PRC_UNPATROLLED,
+                                               'manual' => RecentChange::PRC_PATROLLED,
+                                               'auto' => RecentChange::PRC_AUTOPATROLLED,
+                                       ];
+                                       // e.g. rc_patrolled IN (0, 2)
+                                       $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
+                                               return $rcPatrolledValues[ $s ];
+                                       }, $selected );
+                               }
                        ]
                ];
 
@@ -910,6 +958,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                // information to all users just because the user that saves the edit can
                // patrol or is logged in)
                if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
+                       $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
                        $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
                }
 
@@ -1339,7 +1388,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        }
 
        /**
-        * Replace old options 'hideanons' or 'hideliu' with structured UI equivalent
+        * Replace old options with their structured UI equivalents
         *
         * @param FormOptions $opts
         * @return bool True if the change was made
@@ -1349,21 +1398,40 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        return false;
                }
 
+               $changed = false;
+
                // At this point 'hideanons' and 'hideliu' cannot be both true,
                // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
                if ( $opts[ 'hideanons' ] ) {
                        $opts->reset( 'hideanons' );
                        $opts[ 'userExpLevel' ] = 'registered';
-                       return true;
+                       $changed = true;
                }
 
                if ( $opts[ 'hideliu' ] ) {
                        $opts->reset( 'hideliu' );
                        $opts[ 'userExpLevel' ] = 'unregistered';
-                       return true;
+                       $changed = true;
                }
 
-               return false;
+               if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
+                       if ( $opts[ 'hidepatrolled' ] ) {
+                               $opts->reset( 'hidepatrolled' );
+                               $opts[ 'reviewStatus' ] = 'unpatrolled';
+                               $changed = true;
+                       }
+
+                       if ( $opts[ 'hideunpatrolled' ] ) {
+                               $opts->reset( 'hideunpatrolled' );
+                               $opts[ 'reviewStatus' ] = implode(
+                                       ChangesListStringOptionsFilterGroup::SEPARATOR,
+                                       [ 'manual', 'auto' ]
+                               );
+                               $changed = true;
+                       }
+               }
+
+               return $changed;
        }
 
        /**
index cb2f420..bfef5e0 100644 (file)
@@ -208,8 +208,12 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
                if ( $reviewStatus !== null ) {
                        // Conditional on feature being available and rights
-                       $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
-                       $hidePatrolled->setDefault( $user->getBoolOption( 'hidepatrolled' ) );
+                       if ( $user->getBoolOption( 'hidepatrolled' ) ) {
+                               $reviewStatus->setDefault( 'unpatrolled' );
+                               $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
+                               $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
+                               $legacyHidePatrolled->setDefault( true );
+                       }
                }
 
                $changeType = $this->getFilterGroup( 'changeType' );
index 3fe6c1e..dda1dac 100644 (file)
@@ -264,8 +264,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
                if ( $reviewStatus !== null ) {
                        // Conditional on feature being available and rights
-                       $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
-                       $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
+                       if ( $user->getBoolOption( 'watchlisthidepatrolled' ) ) {
+                               $reviewStatus->setDefault( 'unpatrolled' );
+                               $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
+                               $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
+                               $legacyHidePatrolled->setDefault( true );
+                       }
                }
 
                $authorship = $this->getFilterGroup( 'authorship' );
index 4bdf97e..5cfad4b 100644 (file)
        "rcfilters-filter-humans-label": "Human (not bot)",
        "rcfilters-filter-humans-description": "Edits made by human editors.",
        "rcfilters-filtergroup-reviewstatus": "Review status",
-       "rcfilters-filter-patrolled-label": "Patrolled",
-       "rcfilters-filter-patrolled-description": "Edits marked as patrolled.",
-       "rcfilters-filter-unpatrolled-label": "Unpatrolled",
-       "rcfilters-filter-unpatrolled-description": "Edits not marked as patrolled.",
+       "rcfilters-filter-reviewstatus-unpatrolled-description": "Edits not manually or automatically marked as patrolled.",
+       "rcfilters-filter-reviewstatus-unpatrolled-label": "Unpatrolled",
+       "rcfilters-filter-reviewstatus-manual-description": "Edits manually marked as patrolled.",
+       "rcfilters-filter-reviewstatus-manual-label": "Manually patrolled",
+       "rcfilters-filter-reviewstatus-auto-description": "Edits by advanced users whose work is automatically marked as patrolled.",
+       "rcfilters-filter-reviewstatus-auto-label": "Autopatrolled",
        "rcfilters-filtergroup-significance": "Significance",
        "rcfilters-filter-minor-label": "Minor edits",
        "rcfilters-filter-minor-description": "Edits the author labeled as minor.",
index 6e54765..374dd90 100644 (file)
        "rcfilters-filter-humans-label": "Label for the filter for showing edits made by human editors.",
        "rcfilters-filter-humans-description": "Description for the filter for showing edits made by human editors.",
        "rcfilters-filtergroup-reviewstatus": "Title for the filter group about review status (in core this is whether it's been patrolled)",
-       "rcfilters-filter-patrolled-label": "Label for the filter for showing patrolled edits",
-       "rcfilters-filter-patrolled-description": "Label for the filter showing patrolled edits",
-       "rcfilters-filter-unpatrolled-label": "Label for the filter for showing unpatrolled edits",
-       "rcfilters-filter-unpatrolled-description": "Description for the filter for showing unpatrolled edits",
+       "rcfilters-filter-reviewstatus-manual-description": "Description for the filter showing manually patrolled edits",
+       "rcfilters-filter-reviewstatus-manual-label": "Label for the filter showing manually patrolled edits",
+       "rcfilters-filter-reviewstatus-auto-description": "Description for the filter showing automatically patrolled edits",
+       "rcfilters-filter-reviewstatus-auto-label": "Label for the filter showing automatically patrolled edits",
+       "rcfilters-filter-reviewstatus-unpatrolled-description": "Description for the filter for showing unpatrolled edits",
+       "rcfilters-filter-reviewstatus-unpatrolled-label": "Label for the filter for showing unpatrolled edits",
        "rcfilters-filtergroup-significance": "Title for the filter group for edit significance.\n{{Identical|Significance}}",
        "rcfilters-filter-minor-label": "Label for the filter for showing edits marked as minor.",
        "rcfilters-filter-minor-description": "Description for the filter for showing edits marked as minor.",
index ea5835d..2468c71 100644 (file)
        min-width: 20em;
 }
 
+/* Hide empty live-log textarea */
+#config-live-log textarea:empty {
+       display: none;
+}
+
 /* tooltip styles */
 .config-help-field-hint {
        display: none;
index 7d49a09..76d4bfb 100644 (file)
@@ -51,6 +51,9 @@
                // Parent constructor
                mw.widgets.TitleOptionWidget.parent.call( this, config );
 
+               // Remove check icon
+               this.checkIcon.$element.remove();
+
                // Initialization
                this.$label.attr( 'href', config.url );
                this.$element.addClass( 'mw-widget-titleOptionWidget' );
index 28335ec..844a43f 100644 (file)
@@ -615,9 +615,13 @@ class ParserTestRunner {
                        return false;
                } );// hooks::register
 
+               // Reset the service in case any other tests already cached some prefixes.
+               MediaWikiServices::getInstance()->resetServiceForTesting( 'InterwikiLookup' );
+
                return function () {
                        // Tear down
                        Hooks::clear( 'InterwikiLoadPrefix' );
+                       MediaWikiServices::getInstance()->resetServiceForTesting( 'InterwikiLookup' );
                };
        }
 
index 5118218..aeaa1ae 100644 (file)
@@ -347,7 +347,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
                $user = $this->getTestSysop()->getUser();
                $this->assertConditions(
                        [ # expected
-                               'rc_patrolled = 0',
+                               'rc_patrolled' => 0,
                        ],
                        [
                                'hidepatrolled' => 1,
@@ -361,7 +361,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
                $user = $this->getTestSysop()->getUser();
                $this->assertConditions(
                        [ # expected
-                               'rc_patrolled != 0',
+                               'rc_patrolled' => [ 1, 2 ],
                        ],
                        [
                                'hideunpatrolled' => 1,
@@ -371,6 +371,30 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
                );
        }
 
+       public function testRcReviewStatusFilter() {
+               $user = $this->getTestSysop()->getUser();
+               $this->assertConditions(
+                       [ #expected
+                               'rc_patrolled' => 1,
+                       ],
+                       [
+                               'reviewStatus' => 'manual'
+                       ],
+                       "rc conditions: reviewStatus=manual",
+                       $user
+               );
+               $this->assertConditions(
+                       [ #expected
+                               'rc_patrolled' => [ 0, 2 ],
+                       ],
+                       [
+                               'reviewStatus' => 'unpatrolled;auto'
+                       ],
+                       "rc conditions: reviewStatus=unpatrolled;auto",
+                       $user
+               );
+       }
+
        public function testRcHideminorFilter() {
                $this->assertConditions(
                        [ # expected