X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FdeleteDefaultMessages.php;h=417aa0316666b76a1028afa731a61933dfb73eb2;hb=3d95da4952619f9f773298c4461ccfc646fb18a9;hp=69f4f893fc41acbee33328e442a13d8c7ce2a4ed;hpb=1dd2e07276e1deaf431ddb01c92111038f9e2cd6;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index 69f4f893fc..417aa03166 100644 --- a/maintenance/deleteDefaultMessages.php +++ b/maintenance/deleteDefaultMessages.php @@ -35,6 +35,7 @@ class DeleteDefaultMessages extends Maintenance { parent::__construct(); $this->addDescription( 'Deletes all pages in the MediaWiki namespace' . ' which were last edited by "MediaWiki default"' ); + $this->addOption( 'dry-run', 'Perform a dry run, delete nothing' ); } public function execute() { @@ -52,22 +53,31 @@ class DeleteDefaultMessages extends Maintenance { ); if ( $dbr->numRows( $res ) == 0 ) { - # No more messages left + // No more messages left $this->output( "done.\n" ); + return; + } + $dryrun = $this->hasOption( 'dry-run' ); + if ( $dryrun ) { + foreach ( $res as $row ) { + $title = Title::makeTitle( $row->page_namespace, $row->page_title ); + $this->output( "\n* [[$title]]" ); + } + $this->output( "\n\nRun again without --dry-run to delete these pages.\n" ); return; } - # Deletions will be made by $user temporarly added to the bot group - # in order to hide it in RecentChanges. + // Deletions will be made by $user temporarly added to the bot group + // in order to hide it in RecentChanges. $user = User::newFromName( 'MediaWiki default' ); if ( !$user ) { - $this->error( "Invalid username", true ); + $this->fatalError( "Invalid username" ); } $user->addGroup( 'bot' ); $wgUser = $user; - # Handle deletion + // Handle deletion $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' ); $dbw = $this->getDB( DB_MASTER );