29require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
36 $this->
addOption(
'user',
'The user to perform the undeletion',
false,
true,
'u' );
37 $this->
addOption(
'reason',
'The reason to undelete',
false,
true,
'r' );
38 $this->
addArg(
'pagename',
'Page to undelete' );
42 $username = $this->
getOption(
'user',
false );
43 $reason = $this->
getOption(
'reason',
'' );
44 $pageName = $this->
getArg( 0 );
46 $title = Title::newFromText( $pageName );
50 if ( $username ===
false ) {
51 $user = User::newSystemUser(
'Command line script', [
'steal' =>
true ] );
53 $user = User::newFromName( $username );
60 $this->
output(
"Undeleting " . $title->getPrefixedDBkey() .
"...\n" );
64 ->newUndeletePage( $page, $user )
65 ->undeleteUnsafe( $reason );
68 if ( !$status->isGood() ) {
77require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
commitTransactionRound( $fname)
Commit a transactional batch of DB operations and wait for replica DB servers to catch up.
beginTransactionRound( $fname)
Start a transactional batch of DB operations.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
__construct()
Default constructor.
execute()
Do the actual work.