Merge "qunit: Increase individual test timeout to 60 seconds"
[lhc/web/wiklou.git] / includes / EditPage.php
index 96db74d..277a6cc 100644 (file)
@@ -1202,6 +1202,26 @@ class EditPage {
                return $content;
        }
 
+       /**
+        * Get the edit's parent revision ID
+        *
+        * The "parent" revision is the ancestor that should be recorded in this
+        * page's revision history.  It is either the revision ID of the in-memory
+        * article content, or in the case of a 3-way merge in order to rebase
+        * across a recoverable edit conflict, the ID of the newer revision to
+        * which we have rebased this page.
+        *
+        * @since 1.27
+        * @return int Revision ID
+        */
+       public function getParentRevId() {
+               if ( $this->parentRevId ) {
+                       return $this->parentRevId;
+               } else {
+                       return $this->mArticle->getRevIdFetched();
+               }
+       }
+
        /**
         * Get the current content of the page. This is basically similar to
         * WikiPage::getContent( Revision::RAW ) except that when the page doesn't exist an empty
@@ -1829,7 +1849,7 @@ class EditPage {
                                                $this->page->getComment() == $this->newSectionSummary()
                                        ) {
                                                // Probably a duplicate submission of a new comment.
-                                               // This can happen when squid resends a request after
+                                               // This can happen when CDN resends a request after
                                                // a timeout but the first one actually went through.
                                                wfDebug( __METHOD__
                                                        . ": duplicate new section submission; trigger edit conflict!\n" );
@@ -2122,6 +2142,8 @@ class EditPage {
 
                if ( $result ) {
                        $editContent = $result;
+                       // Update parentRevId to what we just merged.
+                       $this->parentRevId = $currentRevision->getId();
                        return true;
                }
 
@@ -2129,7 +2151,9 @@ class EditPage {
        }
 
        /**
-        * @return Revision
+        * @note: this method is very poorly named. If the user opened the form with ?oldid=X,
+        *        one might think of X as the "base revision", which is NOT what this returns.
+        * @return Revision Current version when the edit was started
         */
        function getBaseRevision() {
                if ( !$this->mBaseRevision ) {
@@ -2582,8 +2606,7 @@ class EditPage {
                $wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
 
                $wgOut->addHTML( Html::hidden( 'oldid', $this->oldid ) );
-               $wgOut->addHTML( Html::hidden( 'parentRevId',
-                       $this->parentRevId ?: $this->mArticle->getRevIdFetched() ) );
+               $wgOut->addHTML( Html::hidden( 'parentRevId', $this->getParentRevId() ) );
 
                $wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) );
                $wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) );
@@ -3434,6 +3457,9 @@ HTML
                global $wgOut;
 
                if ( Hooks::run( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) {
+                       $stats = $wgOut->getContext()->getStats();
+                       $stats->increment( 'edit.failures.conflict' );
+
                        $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourdiff" );
 
                        $content1 = $this->toEditContent( $this->textbox1 );