Quick-fail refreshLinksJob if the triggering revision isn't the latest
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 2 May 2016 20:36:10 +0000 (16:36 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 2 May 2016 20:36:10 +0000 (16:36 -0400)
If we already know that the triggeringRevisionId is outdated, fail early
instead of doing all the work of re-parsing that old revision and
preparing all the updates only to fail later at the lockAndGetLatest()
call.

Change-Id: Ic70c659899d5d47e74fa17c88ed26b436732ca8a

includes/jobqueue/jobs/RefreshLinksJob.php

index 927cafd..c297715 100644 (file)
@@ -154,6 +154,13 @@ class RefreshLinksJob extends Job {
                        return false; // just deleted?
                }
 
+               if ( !$revision->isCurrent() ) {
+                       // If the revision isn't current, there's no point in doing a bunch
+                       // of work just to fail at the lockAndGetLatest() check later.
+                       $this->setLastError( "Revision {$revision->getId()} is not current" );
+                       return false;
+               }
+
                $content = $revision->getContent( Revision::RAW );
                if ( !$content ) {
                        // If there is no content, pretend the content is empty