Merge "Add User::isSafeToLoad() and ParserOptions::newFromAnon()"
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index aada064..078f032 100644 (file)
@@ -51,6 +51,10 @@ class PageArchive {
                $this->config = $config;
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        /**
         * List all deleted pages recorded in the archive table. Returns result
         * wrapper with (ar_namespace, ar_title, count) fields, ordered by page
@@ -568,7 +572,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...
@@ -1701,15 +1709,7 @@ class SpecialUndelete extends SpecialPage {
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit, $offset ) {
-               $title = Title::newFromText( $search );
-               if ( !$title || !$title->canExist() ) {
-                       // No prefix suggestion in special and media namespace
-                       return array();
-               }
-               // Autocomplete subpage the same as a normal search
-               $prefixSearcher = new StringPrefixSearch;
-               $result = $prefixSearcher->search( $search, $limit, array(), $offset );
-               return $result;
+               return $this->prefixSearchString( $search, $limit, $offset );
        }
 
        protected function getGroupName() {