Fix watchlist "in the last X hours" display
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 27 Sep 2017 12:01:58 +0000 (08:01 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 27 Sep 2017 12:01:58 +0000 (08:01 -0400)
If6280ad6 changed the interpretation of the URL parameter "days=0" (or
any negative value) from meaning "maximum number of days" to actually
meaning "0 days". That's a somewhat annoying breaking change, but easily
worked around by updating bookmarks.

But it didn't update the display on the page, so despite querying 0 days
it would still incorrectly say something like "in the last 720 hours"
rather than "in the last 0 hours".

Bug: T176857
Change-Id: I90c79ef9c4819a34060515b863277fd185828ed9

includes/specials/SpecialWatchlist.php

index 531184b..8a47486 100644 (file)
@@ -608,11 +608,6 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
 
                $lang = $this->getLanguage();
-               if ( $opts['days'] > 0 ) {
-                       $days = $opts['days'];
-               } else {
-                       $days = $this->maxDays;
-               }
                $timestamp = wfTimestampNow();
                $wlInfo = Html::rawElement(
                        'span',
@@ -620,7 +615,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                'class' => 'wlinfo',
                                'data-params' => json_encode( [ 'from' => $timestamp ] ),
                        ],
-                       $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
+                       $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
                                $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
                        )->parse()
                ) . "<br />\n";