33require_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... " );
110 $page = WikiPage::factory(
$title );
112 $success = $page->doDeleteArticle( $reason,
false,
null,
null, $error, $user,
true );
114 $this->
output(
" Deleted!\n" );
116 $this->
output(
" FAILED to delete article\n" );
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
const RUN_MAINTENANCE_IF_MAIN
Maintenance script to delete a batch of pages.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
getStdin( $len=null)
Return input from stdin.
hasArg( $argId=0)
Does a given argument exist?
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.