Use ar_page_id on undeletion
authorvictorbarbu <victorbarbu08@gmail.com>
Mon, 11 Jan 2016 21:52:21 +0000 (23:52 +0200)
committerVictorbarbu <victorbarbu08@gmail.com>
Mon, 11 Jan 2016 23:09:50 +0000 (23:09 +0000)
Bug: T28123
Change-Id: I882b8ba09d68e7475e1d0934328730059574e292

includes/page/WikiPage.php
includes/specials/SpecialUndelete.php

index 00ac127..e3e6e15 100644 (file)
@@ -1158,6 +1158,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                return true;
        }
+
        /**
         * Insert a new empty page record for this article.
         * This *must* be followed up by creating a revision
@@ -1166,13 +1167,16 @@ class WikiPage implements Page, IDBAccessObject {
         * Best if all done inside a transaction.
         *
         * @param IDatabase $dbw
-        * @return int|bool The newly created page_id key; false if the title already existed
+        * @param int|null $pageId Custom page ID that will be used for the insert statement
+        *
+        * @return bool|int The newly created page_id key; false if the title already existed
         */
-       public function insertOn( $dbw ) {
+       public function insertOn( $dbw, $pageId = null ) {
+               $pageId = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' );
                $dbw->insert(
                        'page',
                        array(
-                               'page_id'           => $dbw->nextSequenceValue( 'page_page_id_seq' ),
+                               'page_id'           => $pageId,
                                'page_namespace'    => $this->mTitle->getNamespace(),
                                'page_title'        => $this->mTitle->getDBkey(),
                                'page_restrictions' => '',
index aada064..b36860f 100644 (file)
@@ -568,7 +568,7 @@ class PageArchive {
                                return Status::newFatal( "undeleterevdel" );
                        }
                        // Safe to insert now...
-                       $newid = $article->insertOn( $dbw );
+                       $newid = $article->insertOn( $dbw, $row->ar_page_id );
                        $pageId = $newid;
                } else {
                        // Check if a deleted revision will become the current revision...