Make export depth > 1 actually work. :) Assuming it doesn't bomb and die using too...
[mediawiki.git] / maintenance / undelete.php
blobb7b7df979e3a6b48bb4b8ae1cb481732ce62a362
1 <?php
2 /**
3 * Undelete a page by fetching it from the archive table
5 * @file
6 * @ingroup Maintenance
7 */
9 $usage = <<<EOT
10 Undelete a page
11 Usage: php undelete.php [-u <user>] [-r <reason>] <pagename>
13 EOT;
15 $optionsWithArgs = array( 'u', 'r' );
16 require_once( 'commandLine.inc' );
18 $user = 'Command line script';
19 $reason = '';
21 if ( isset( $options['u'] ) ) {
22 $user = $options['u'];
24 if ( isset( $options['r'] ) ) {
25 $reason = $options['r'];
27 $pageName = @$args[0];
28 $title = Title::newFromText( $pageName );
29 if ( !$title ) {
30 echo $usage;
31 exit( 1 );
33 $wgUser = User::newFromName( $user );
34 $archive = new PageArchive( $title );
35 echo "Undeleting " . $title->getPrefixedDBkey() . '...';
36 $archive->undelete( array(), $reason );
37 echo "done\n";