Revision::newNullRevision don't pass null to RevisionStore
authoraddshore <addshorewiki@gmail.com>
Thu, 11 Jan 2018 09:22:16 +0000 (09:22 +0000)
committeraddshore <addshorewiki@gmail.com>
Thu, 11 Jan 2018 09:22:16 +0000 (09:22 +0000)
RevisionStore::newNullRevision must be passed a Title object when
being used, passing null will result in a fatal.

Title::newFromID can return null, so check and return null early if we
have no Title object.

Also use Title::GAID_FOR_UPDATE for a higher chance of getting a Title.
Prior to the Revision overhaul newNullRevision would have always done a
select from master, it is documented as accepting $dbw and also passed
FOR UPDATE as an option to selectRow.

Bug: T184687
Change-Id: If1f99d091ab9cd37d514a4f4cbf3c28b64426cb7

includes/Revision.php

index 0844e89..b653f7f 100644 (file)
@@ -1065,7 +1065,11 @@ class Revision implements IDBAccessObject {
 
                $comment = CommentStoreComment::newUnsavedComment( $summary, null );
 
-               $title = Title::newFromID( $pageId );
+               $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
+               if ( $title === null ) {
+                       return null;
+               }
+
                $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
 
                return new Revision( $rec );