Go to the documentation of this file.
33 require_once __DIR__ .
'/Maintenance.php';
43 parent::__construct();
45 $this->
addOption(
'u',
"User to perform deletion",
false,
true );
46 $this->
addOption(
'r',
"Reason to delete page",
false,
true );
47 $this->
addOption(
'i',
"Interval to sleep between deletions" );
48 $this->
addArg(
'listfile',
'File with titles to delete, separated by newlines. ' .
49 'If not given, stdin will be used.',
false );
55 # Change to current working directory
60 $username = $this->
getOption(
'u',
false );
64 if ( $username ===
false ) {
74 if ( $this->
hasArg( 0 ) ) {
82 $this->
fatalError(
"Unable to read file, exiting" );
86 for ( $linenum = 1; !feof(
$file ); $linenum++ ) {
93 $this->
output(
"Invalid title '$line' on line $linenum\n" );
97 $this->
output(
"Skipping nonexistent page '$line'\n" );
103 $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
104 $title, [
'ignoreRedirect' =>
true ]
106 if ( $img && $img->isLocal() && !$img->delete( $reason ) ) {
107 $this->
output(
" FAILED to delete associated file... " );
112 $success = $page->doDeleteArticle( $reason,
false,
null,
null, $error, $user,
true );
114 $this->
output(
" Deleted!\n" );
116 $this->
output(
" FAILED to delete article\n" );
const RUN_MAINTENANCE_IF_MAIN
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getStdin( $len=null)
Return input from stdin.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addDescription( $text)
Set the description text.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
hasArg( $argId=0)
Does a given argument exist?
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
__construct()
Default constructor.
Maintenance script to delete a batch of pages.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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.
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
getArg( $argId=0, $default=null)
Get an argument.