Merge "Avoid races on null revision insertion"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 25 Jan 2016 20:20:10 +0000 (20:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 25 Jan 2016 20:20:10 +0000 (20:20 +0000)
1  2 
includes/Revision.php

diff --combined includes/Revision.php
@@@ -1366,17 -1366,6 +1366,17 @@@ class Revision implements IDBAccessObje
        public function insertOn( $dbw ) {
                global $wgDefaultExternalStore, $wgContentHandlerUseDB;
  
 +              // Not allowed to have rev_page equal to 0, false, etc.
 +              if ( !$this->mPage ) {
 +                      $title = $this->getTitle();
 +                      if ( $title instanceof Title ) {
 +                              $titleText = ' for page ' . $title->getPrefixedText();
 +                      } else {
 +                              $titleText = '';
 +                      }
 +                      throw new MWException( "Cannot insert revision$titleText: page ID must be nonzero" );
 +              }
 +
                $this->checkContentModel();
  
                $data = $this->mText;
                        array(
                                'page_id' => $pageId,
                                'page_latest=rev_id',
-                               ),
-                       __METHOD__ );
+                       ),
+                       __METHOD__,
+                       array( 'FOR UPDATE' ) // T51581
+               );
  
                if ( $current ) {
                        if ( !$user ) {