Report correct rev_id in missing-revision message
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 7 Apr 2015 15:11:21 +0000 (11:11 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 7 Apr 2015 15:11:21 +0000 (11:11 -0400)
When trying to fetch the current revision, it currently always reports
"0" even when it's trying to fetch some other revision.

Bug: T92046
Change-Id: Ia5eb73ac32de0f654ac28ee929d5c4dda71c2f1b

includes/page/Article.php

index eb597d2..91e9971 100644 (file)
@@ -378,7 +378,7 @@ class Article implements Page {
                # Pre-fill content with error message so that if something
                # fails we'll have something telling us what we intended.
                //XXX: this isn't page content but a UI message. horrible.
-               $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() );
+               $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ) );
 
                if ( $oldid ) {
                        # $this->mRevision might already be fetched by getOldIDFromRequest()
@@ -390,17 +390,20 @@ class Article implements Page {
                                }
                        }
                } else {
-                       if ( !$this->mPage->getLatest() ) {
+                       $oldid = $this->mPage->getLatest();
+                       if ( !$oldid ) {
                                wfDebug( __METHOD__ . " failed to find page data for title " .
                                        $this->getTitle()->getPrefixedText() . "\n" );
                                return false;
                        }
 
+                       # Update error message with correct oldid
+                       $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ) );
+
                        $this->mRevision = $this->mPage->getRevision();
 
                        if ( !$this->mRevision ) {
-                               wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " .
-                                       $this->mPage->getLatest() . "\n" );
+                               wfDebug( __METHOD__ . " failed to retrieve current page, rev_id $oldid\n" );
                                return false;
                        }
                }