From: jenkins-bot Date: Thu, 12 Apr 2018 16:27:03 +0000 (+0000) Subject: Merge "Improve test coverage for ApiParse" X-Git-Tag: 1.31.0-rc.0~106 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=91bdb5c431292099b0c9fcc587d0afacba837264;hp=84db63aa6f0482f12ddf2b207944e942aaaf4d4c;p=lhc%2Fweb%2Fwiklou.git Merge "Improve test coverage for ApiParse" --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index eb2cadaee9..2a4acc86ab 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -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; } /** diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index cb2f42009c..bfef5e0363 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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' ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 3fe6c1e022..dda1dac3af 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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' ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 4bdf97e1ba..5cfad4bbc3 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1441,10 +1441,12 @@ "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.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 6e54765e83..374dd9072a 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1638,10 +1638,12 @@ "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.", diff --git a/mw-config/config.css b/mw-config/config.css index ea5835d487..2468c71563 100644 --- a/mw-config/config.css +++ b/mw-config/config.css @@ -174,6 +174,11 @@ min-width: 20em; } +/* Hide empty live-log textarea */ +#config-live-log textarea:empty { + display: none; +} + /* tooltip styles */ .config-help-field-hint { display: none; diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js index 7d49a09b5e..76d4bfbac6 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js @@ -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' ); diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 28335ecdde..844a43f34a 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -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' ); }; } diff --git a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php index 51182180a9..aeaa1aee9e 100644 --- a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php +++ b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php @@ -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