Make sure $content is always defined
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Dec 2013 17:24:15 +0000 (09:24 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Dec 2013 17:24:15 +0000 (09:24 -0800)
* Fixes 48a77e1

bug: 57916
Change-Id: I3cc0f36467da31a668bf27d5033555fa59e43c39

includes/job/jobs/RefreshLinksJob.php

index e5f3ce5..e81998d 100644 (file)
@@ -119,6 +119,18 @@ class RefreshLinksJob extends Job {
                        wfGetLB()->waitFor( $this->params['masterPos'] );
                }
 
+               // Fetch the current revision...
+               $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
+               if ( !$revision ) {
+                       $this->setLastError( "refreshLinks: Article not found {$title->getPrefixedDBkey()}" );
+                       return false; // XXX: what if it was just deleted?
+               }
+               $content = $revision->getContent( Revision::RAW );
+               if ( !$content ) {
+                       // If there is no content, pretend the content is empty
+                       $content = $revision->getContentHandler()->makeEmptyContent();
+               }
+
                $parserOutput = false;
                // If page_touched changed after this root job (with a good slave lag skew factor),
                // then it is likely that any views of the pages already resulted in re-parses which
@@ -136,18 +148,6 @@ class RefreshLinksJob extends Job {
                }
                // Fetch the current revision and parse it if necessary...
                if ( $parserOutput == false ) {
-                       $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
-                       if ( !$revision ) {
-                               $this->setLastError( "refreshLinks: Article not found {$title->getPrefixedDBkey()}" );
-                               return false; // XXX: what if it was just deleted?
-                       }
-
-                       $content = $revision->getContent( Revision::RAW );
-                       if ( !$content ) {
-                               // If there is no content, pretend the content is empty
-                               $content = $revision->getContentHandler()->makeEmptyContent();
-                       }
-
                        // Revision ID must be passed to the parser output to get revision variables correct
                        $parserOutput = $content->getParserOutput( $title, $revision->getId(), null, false );
                }