RevisionDelete - Improved handling of page moves
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 22 Mar 2009 01:16:15 +0000 (01:16 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 22 Mar 2009 01:16:15 +0000 (01:16 +0000)
includes/specials/SpecialRevisiondelete.php

index 249984d..9e367f5 100644 (file)
@@ -38,12 +38,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $this->fileids = $wgRequest->getArray( 'fileid' );
                # For reviewing deleted files...
                $this->file = $wgRequest->getVal( 'file' );
-               # If this is a revision, then we need a target page
-               $this->page = Title::newFromUrl( $this->target );
-               if( is_null($this->page) ) {
-                       $wgOut->addWikiMsg( 'undelete-header' );
-                       return;
-               }
                # Only one target set at a time please!
                $i = (bool)$this->file + (bool)$this->oldids + (bool)$this->logids
                        + (bool)$this->artimestamps + (bool)$this->fileids + (bool)$this->oldimgs;
@@ -51,6 +45,18 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $wgOut->showErrorPage( 'revdelete-toomanytargets-title', 'revdelete-toomanytargets-text' );
                        return;
                }
+               $this->page = Title::newFromUrl( $this->target );
+               # If this is just one revision, get the title from it.
+               # This allows for more flexibility with page moves...
+               if( count($this->oldids) === 1 ) {
+                       $rev = Revision::newFromId( $this->oldids[0] );
+                       $this->page = $rev ? $rev->getTitle() : $this->page;
+               }
+               # We need a target page!
+               if( is_null($this->page) ) {
+                       $wgOut->addWikiMsg( 'undelete-header' );
+                       return;
+               }
                # Logs must have a type given
                if( $this->logids && !strpos($this->page->getDBKey(),'/') ) {
                        $wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-text' );