Fall back to autoincrement when page cannot be recreated with old ID
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index aada064..744a090 100644 (file)
@@ -568,7 +568,11 @@ class PageArchive {
                                return Status::newFatal( "undeleterevdel" );
                        }
                        // Safe to insert now...
-                       $newid = $article->insertOn( $dbw );
+                       $newid = $article->insertOn( $dbw, $row->ar_page_id );
+                       if ( $newid === false ) {
+                               // The old ID is reserved; let's pick another
+                               $newid = $article->insertOn( $dbw );
+                       }
                        $pageId = $newid;
                } else {
                        // Check if a deleted revision will become the current revision...