WatchedItemStore: Fix fatal when revision is deleted
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 10 Jul 2019 20:15:20 +0000 (13:15 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 10 Jul 2019 20:15:20 +0000 (13:15 -0700)
People following links from their watchlist emails to since-deleted
revisions were getting fatals from
WatchedItemStore::getNotificationTimestamp().

It's hard to tell whether returning null or false is the right thing to
do here, because this function can return both and the difference is not
documented, and I wasn't able to find any callers that care about the
distinction.

Bug: T226741
Change-Id: Ib2a836099343f4c161227266dbeeafbc76dccc2b

includes/watcheditem/WatchedItemStore.php

index 1a39945..d33b6ae 100644 (file)
@@ -1120,6 +1120,11 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                }
 
                $oldRev = $this->revisionLookup->getRevisionById( $oldid );
+               if ( !$oldRev ) {
+                       // Oldid given but does not exist (probably deleted)
+                       return false;
+               }
+
                $nextRev = $this->revisionLookup->getNextRevision( $oldRev );
                if ( !$nextRev ) {
                        // Oldid given and is the latest revision for this title; clear the timestamp.