Merge "Relax SpecialPageFatalTest about deprecation notices"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 6defc9d..c326257 100644 (file)
@@ -193,11 +193,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                        'cssClassSuffix' => 'watchedunseen',
                                        'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
                                                $changeTs = $rc->getAttribute( 'rc_timestamp' );
-                                               $lastVisitTs = $this->watchStore->getLatestNotificationTimestamp(
-                                                       $rc->getAttribute( 'wl_notificationtimestamp' ),
-                                                       $rc->getPerformer(),
-                                                       $rc->getTitle()
-                                               );
+                                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
+
                                                return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
                                        },
                                ],
@@ -206,16 +203,26 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                        'label' => 'rcfilters-filter-watchlistactivity-seen-label',
                                        'description' => 'rcfilters-filter-watchlistactivity-seen-description',
                                        'cssClassSuffix' => 'watchedseen',
-                                       'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                       'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
                                                $changeTs = $rc->getAttribute( 'rc_timestamp' );
-                                               $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
+                                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
+
                                                return $lastVisitTs === null || $changeTs < $lastVisitTs;
                                        }
                                ],
                        ],
                        'default' => ChangesListStringOptionsFilterGroup::NONE,
-                       'queryCallable' => function ( $specialPageClassName, $context, $dbr,
-                                       &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
+                       'queryCallable' => function (
+                               $specialPageClassName,
+                               $context,
+                               IDatabase $dbr,
+                               &$tables,
+                               &$fields,
+                               &$conds,
+                               &$query_options,
+                               &$join_conds,
+                               $selectedValues
+                       ) {
                                if ( $selectedValues === [ 'seen' ] ) {
                                        $conds[] = $dbr->makeList( [
                                                'wl_notificationtimestamp IS NULL',
@@ -534,7 +541,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $rc->counter = $counter++;
 
                        if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
-                               $updated = $obj->wl_notificationtimestamp;
+                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
+                               $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) );
                        } else {
                                $updated = false;
                        }
@@ -598,11 +606,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $lang = $this->getLanguage();
                $timestamp = wfTimestampNow();
+               $now = $lang->userTimeAndDate( $timestamp, $user );
                $wlInfo = Html::rawElement(
                        'span',
                        [
                                'class' => 'wlinfo',
-                               'data-params' => json_encode( [ 'from' => $timestamp ] ),
+                               'data-params' => json_encode( [ 'from' => $timestamp, 'fromFormatted' => $now ] ),
                        ],
                        $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
                                $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
@@ -699,15 +708,16 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                if ( $this->isStructuredFilterUiEnabled() ) {
                        $rcfilterContainer = Html::element(
                                'div',
-                               [ 'class' => 'rcfilters-container' ]
+                               // TODO: Remove deprecated rcfilters-container class
+                               [ 'class' => 'rcfilters-container mw-rcfilters-container' ]
                        );
 
                        $loadingContainer = Html::rawElement(
                                'div',
-                               [ 'class' => 'rcfilters-spinner' ],
+                               [ 'class' => 'mw-rcfilters-spinner' ],
                                Html::element(
                                        'div',
-                                       [ 'class' => 'rcfilters-spinner-bounce' ]
+                                       [ 'class' => 'mw-rcfilters-spinner-bounce' ]
                                )
                        );
 
@@ -715,7 +725,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $this->getOutput()->addHTML(
                                Html::rawElement(
                                        'div',
-                                       [ 'class' => 'rcfilters-head' ],
+                                       // TODO: Remove deprecated rcfilters-head class
+                                       [ 'class' => 'rcfilters-head mw-rcfilters-head' ],
                                        $rcfilterContainer . $form
                                )
                        );
@@ -848,4 +859,16 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $count = $store->countWatchedItems( $this->getUser() );
                return floor( $count / 2 );
        }
+
+       /**
+        * @param RecentChange $rc
+        * @return string TS_MW timestamp
+        */
+       protected function getLatestSeenTimestamp( RecentChange $rc ) {
+               return $this->watchStore->getLatestNotificationTimestamp(
+                       $rc->getAttribute( 'wl_notificationtimestamp' ),
+                       $rc->getPerformer(),
+                       $rc->getTitle()
+               );
+       }
 }