watchlist: cleanup various method/variable names and comments in watchlist/store...
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 10 May 2019 00:37:58 +0000 (17:37 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 10 May 2019 00:44:16 +0000 (17:44 -0700)
Change-Id: I70a55d5b4ea38f92132a15da3feb314b6b5bb013

includes/changes/RCCacheEntry.php
includes/specials/SpecialWatchlist.php
includes/watcheditem/WatchedItemStore.php
includes/watcheditem/WatchedItemStoreInterface.php

index 9f85aa1..6d9236a 100644 (file)
  */
 
 class RCCacheEntry extends RecentChange {
+       /** @var string|null */
        public $curlink;
+       /** @var string|null */
        public $difflink;
+       /** @var string|null */
        public $lastlink;
+       /** @var string|null */
        public $link;
+       /** @var string|null */
        public $timestamp;
+       /** @var bool|null */
        public $unpatrolled;
+       /** @var string|null */
        public $userlink;
+       /** @var string|null */
        public $usertalklink;
+       /** @var bool|null */
        public $watched;
-       public $mAttribs;
-       public $mExtra;
 
        /**
         * @param RecentChange $rc
index 812f1b0..1ef11b5 100644 (file)
@@ -865,16 +865,16 @@ 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(),
index bd4360e..ec25002 100644 (file)
@@ -1103,6 +1103,14 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                return "{$target->getNamespace()}:{$target->getDBkey()}";
        }
 
+       /**
+        * @param UserIdentity $user
+        * @param LinkTarget $title
+        * @param WatchedItem $item
+        * @param bool $force
+        * @param int|bool $oldid The ID of the last revision that the user viewed
+        * @return bool|string|null
+        */
        private function getNotificationTimestamp(
                UserIdentity $user, LinkTarget $title, $item, $force, $oldid
        ) {
@@ -1112,7 +1120,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                }
 
                $oldRev = $this->revisionLookup->getRevisionById( $oldid );
-               if ( !$this->revisionLookup->getNextRevision( $oldRev, $title ) ) {
+               $nextRev = $this->revisionLookup->getNextRevision( $oldRev, $title );
+               if ( !$nextRev ) {
                        // Oldid given and is the latest revision for this title; clear the timestamp.
                        return null;
                }
@@ -1129,6 +1138,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                // Oldid given and isn't the latest; update the timestamp.
                // This will result in no further notification emails being sent!
                $notificationTimestamp = $this->revisionLookup->getTimestampFromId( $oldid );
+               // @FIXME: this should use getTimestamp() for consistency with updates on new edits
+               // $notificationTimestamp = $nextRev->getTimestamp(); // first unseen revision timestamp
 
                // We need to go one second to the future because of various strict comparisons
                // throughout the codebase
index 5ff29d0..1cf3288 100644 (file)
@@ -239,7 +239,7 @@ interface WatchedItemStoreInterface {
         * @param UserIdentity $editor The editor that triggered the update. Their notification
         *  timestamp will not be updated(they have already seen it)
         * @param LinkTarget $target The target to update timestamps for
-        * @param string $timestamp Set the update timestamp to this value
+        * @param string $timestamp Set the update (first unseen revision) timestamp to this value
         *
         * @return int[] Array of user IDs the timestamp has been updated for
         */
@@ -341,7 +341,7 @@ interface WatchedItemStoreInterface {
         * @param string|null $timestamp Value of wl_notificationtimestamp from the DB
         * @param UserIdentity $user
         * @param LinkTarget $target
-        * @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
         */
        public function getLatestNotificationTimestamp(
                $timestamp, UserIdentity $user, LinkTarget $target );