Merge "output: Narrow Title type hint to LinkTarget"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 812f1b0..84b3331 100644 (file)
@@ -148,6 +148,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
        /**
         * @inheritDoc
+        * @suppress PhanUndeclaredMethod
         */
        protected function registerFilters() {
                parent::registerFilters();
@@ -380,9 +381,10 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                // Log entries with DELETED_ACTION must not show up unless the user has
                // the necessary rights.
-               if ( !$user->isAllowed( 'deletedhistory' ) ) {
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+               if ( !$permissionManager->userHasRight( $user, 'deletedhistory' ) ) {
                        $bitmask = LogPage::DELETED_ACTION;
-               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
+               } elseif ( !$permissionManager->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' ) ) {
                        $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
                } else {
                        $bitmask = 0;
@@ -554,6 +556,9 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                $rc->numberofWatchingusers = 0;
                        }
 
+                       // XXX: this treats pages with no unseen changes as "not on the watchlist" since
+                       // everything is on the watchlist and it is an easy way to make pages with unseen
+                       // changes appear bold. @TODO: clean this up.
                        $changeLine = $list->recentChangesLine( $rc, $unseen, $counter );
                        if ( $changeLine !== false ) {
                                $s .= $changeLine;
@@ -865,19 +870,19 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @return bool User viewed the revision or a newer one
         */
        protected function isChangeEffectivelySeen( RecentChange $rc ) {
-               $lastVisitTs = $this->getLatestSeenTimestampIfHasUnseen( $rc );
+               $firstUnseen = $this->getLatestNotificationTimestamp( $rc );
 
-               return $lastVisitTs === null || $lastVisitTs > $rc->getAttribute( 'rc_timestamp' );
+               return ( $firstUnseen === null || $firstUnseen > $rc->getAttribute( 'rc_timestamp' ) );
        }
 
        /**
         * @param RecentChange $rc
-        * @return string|null TS_MW timestamp or null if all revision were seen
+        * @return string|null TS_MW timestamp of first unseen revision or null if there isn't one
         */
-       private function getLatestSeenTimestampIfHasUnseen( RecentChange $rc ) {
+       private function getLatestNotificationTimestamp( RecentChange $rc ) {
                return $this->watchStore->getLatestNotificationTimestamp(
                        $rc->getAttribute( 'wl_notificationtimestamp' ),
-                       $rc->getPerformer(),
+                       $this->getUser(),
                        $rc->getTitle()
                );
        }