3 * Undelete a page by fetching it from the archive table
9 require_once( dirname(__FILE__
) . '/Maintenance.php' );
11 class Undelete
extends Maintenance
{
12 public function __construct() {
13 parent
::__construct();
14 $this->mDescription
= "Undelete a page";
15 $this->addOption( 'u', 'The user to perform the undeletion', false, true );
16 $this->addOption( 'r', 'The reason to undelete', false, true );
17 $this->addArg( 'pagename', 'Page to undelete' );
20 public function execute() {
23 $user = $this->getOption( 'u', 'Command line script' );
24 $reason = $this->getOption( 'r', '' );
25 $pageName = $this->getArg();
27 $title = Title
::newFromText( $pageName );
29 $this->error( "Invalid title", true );
31 $wgUser = User
::newFromName( $user );
32 $archive = new PageArchive( $title );
33 $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' );
34 $archive->undelete( array(), $reason );
35 $this->output( "done\n" );
39 $maintClass = "Undelete";
40 require_once( DO_MAINTENANCE
);