For back-compat, keep the default as-is, because it is also
used as a post-update script by the installer.
But for convenience and safe manual use, do add a dry-run option.
(Ideally this would be a --delete option and dry-run by default.)
Change-Id: I3ca70f15f50b66f9d19fa705cef9a4aae2dd4e5c
parent::__construct();
$this->addDescription( 'Deletes all pages in the MediaWiki namespace' .
' which were last edited by "MediaWiki default"' );
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() {
}
public function execute() {
);
if ( $dbr->numRows( $res ) == 0 ) {
);
if ( $dbr->numRows( $res ) == 0 ) {
- # No more messages left
+ // No more messages left
$this->output( "done.\n" );
$this->output( "done.\n" );
+ $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" );
- # 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 );
$user = User::newFromName( 'MediaWiki default' );
if ( !$user ) {
$this->error( "Invalid username", true );
$user->addGroup( 'bot' );
$wgUser = $user;
$user->addGroup( 'bot' );
$wgUser = $user;
$this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
$dbw = $this->getDB( DB_MASTER );
$this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
$dbw = $this->getDB( DB_MASTER );