X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=f716e920f062e77d4aa57c0ed8f5aba11cc50cf8;hb=6f3d5a5204770b7e9076ec0c956631c32a9e1114;hp=b9543d9bf6c31c7741294e3618ebaebf7459a713;hpb=75c03d08fa8d235af7b4fcd8554686c666ba0268;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index b9543d9bf6..432cfcc2f9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -289,20 +289,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { } } - /** - * Get all custom filters - * - * @return array Map of filter URL param names to properties (msg/default) - */ - protected function getCustomFilters() { - if ( $this->customFilters === null ) { - $this->customFilters = parent::getCustomFilters(); - Hooks::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters ], '1.23' ); - } - - return $this->customFilters; - } - /** * Fetch values for a FormOptions object from the WebRequest associated with this instance. * @@ -493,9 +479,10 @@ class SpecialWatchlist extends ChangesListSpecialPage { $dbr = $this->getDB(); $user = $this->getUser(); $output = $this->getOutput(); + $services = MediaWikiServices::getInstance(); # Show a message about replica DB lag, if applicable - $lag = MediaWikiServices::getInstance()->getDBLoadBalancer()->safeGetLag( $dbr ); + $lag = $services->getDBLoadBalancer()->safeGetLag( $dbr ); if ( $lag > 0 ) { $output->showLagWarning( $lag ); } @@ -526,7 +513,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { $this->msg( 'watchlist-unwatch' )->text(), [ 'class' => 'mw-unwatch-link', 'title' => $this->msg( 'tooltip-ca-unwatch' )->text() - ], [ 'action' => 'unwatch' ] ) . ' '; + ], [ 'action' => 'unwatch' ] ) . "\u{00A0}"; } } ); } @@ -535,7 +522,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { if ( $this->getConfig()->get( 'RCShowWatchingUsers' ) && $user->getOption( 'shownumberswatching' ) ) { - $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore(); + $watchedItemStore = $services->getWatchedItemStore(); } $s = $list->beginRecentChangesList(); @@ -756,45 +743,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', (float)( $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, (float)( $value / 24 ) ); } return $select->getHTML() . "\n
\n";