Use InvalidArgumentException in ActivityUpdateJob
[lhc/web/wiklou.git] / includes / Revision.php
index 1d7ac72..f4f6dca 100644 (file)
@@ -1366,6 +1366,17 @@ class Revision implements IDBAccessObject {
        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;
@@ -1628,8 +1639,10 @@ class Revision implements IDBAccessObject {
                        array(
                                'page_id' => $pageId,
                                'page_latest=rev_id',
-                               ),
-                       __METHOD__ );
+                       ),
+                       __METHOD__,
+                       array( 'FOR UPDATE' ) // T51581
+               );
 
                if ( $current ) {
                        if ( !$user ) {