X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=55a7f0391f422f0914521006e18c166843d54882;hp=3fe6c1e022e492c2f6545afca2c61f18bb3318f9;hb=96998d51f9788b0397c93b00a4ebfcfd4ed85c54;hpb=62e3318f82ebc1638d504cef155200999952d31a diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 3fe6c1e022..55a7f0391f 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' ); @@ -747,45 +751,36 @@ class SpecialWatchlist extends ChangesListSpecialPage { } function cutoffselector( $options ) { - // Cast everything to strings immediately, so that we know all of the values have the same - // precision, and can be compared with '==='. 2/24 has a few more decimal places than its - // default string representation, for example, and would confuse comparisons. - - // Misleadingly, the 'days' option supports hours too. - $days = array_map( 'strval', [ 1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7 ] ); - - $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' ); - // add the user preference, if it isn't available already - if ( !in_array( $userWatchlistOption, $days ) && $userWatchlistOption !== '0' ) { - $days[] = $userWatchlistOption; - } - - $maxDays = (string)$this->maxDays; - // add the maximum possible value, if it isn't available already - if ( !in_array( $maxDays, $days ) ) { - $days[] = $maxDays; - } - - $selected = (string)$options['days']; + $selected = (float)$options['days']; if ( $selected <= 0 ) { - $selected = $maxDays; - } - - // add the currently selected value, if it isn't available already - if ( !in_array( $selected, $days ) ) { - $days[] = $selected; - } + $selected = $this->maxDays; + } + + $selectedHours = round( $selected * 24 ); + + $hours = array_unique( array_filter( [ + 1, + 2, + 6, + 12, + 24, + 72, + 168, + 24 * (float)$this->getUser()->getOption( 'watchlistdays', 0 ), + 24 * $this->maxDays, + $selectedHours + ] ) ); + asort( $hours ); - $select = new XmlSelect( 'days', 'days', $selected ); + $select = new XmlSelect( 'days', 'days', $selectedHours / 24 ); - asort( $days ); - foreach ( $days as $value ) { - if ( $value < 1 ) { - $name = $this->msg( 'hours' )->numParams( $value * 24 )->text(); + foreach ( $hours as $value ) { + if ( $value < 24 ) { + $name = $this->msg( 'hours' )->numParams( $value )->text(); } else { - $name = $this->msg( 'days' )->numParams( $value )->text(); + $name = $this->msg( 'days' )->numParams( $value / 24 )->text(); } - $select->addOption( $name, $value ); + $select->addOption( $name, $value / 24 ); } return $select->getHTML() . "\n
\n";