Use READ_LATEST for the WikiPage in RefreshLinksJob
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 10 Jul 2016 11:14:12 +0000 (04:14 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 10 Jul 2016 11:14:12 +0000 (04:14 -0700)
Also sanity check that the revision belongs to that page.

Change-Id: I4e6897b52212d9787d74fb017861ec62f2927f0e

includes/jobqueue/jobs/RefreshLinksJob.php

index 8870569..c76ea4f 100644 (file)
@@ -129,6 +129,7 @@ class RefreshLinksJob extends Job {
         */
        protected function runForTitle( Title $title ) {
                $page = WikiPage::factory( $title );
+               $page->loadPageData( WikiPage::READ_LATEST );
                if ( !empty( $this->params['triggeringRevisionId'] ) ) {
                        // Fetch the specified revision; lockAndGetLatest() below detects if the page
                        // was edited since and aborts in order to avoid corrupting the link tables
@@ -147,7 +148,7 @@ class RefreshLinksJob extends Job {
                        $stats->increment( 'refreshlinks.rev_not_found' );
                        $this->setLastError( "Revision not found for {$title->getPrefixedDBkey()}" );
                        return false; // just deleted?
-               } elseif ( !$revision->isCurrent() ) {
+               } elseif ( !$revision->isCurrent() || $revision->getPage() != $page->getId() ) {
                        // If the revision isn't current, there's no point in doing a bunch
                        // of work just to fail at the lockAndGetLatest() check later.
                        $stats->increment( 'refreshlinks.rev_not_current' );