@@ -35,6 +35,7 @@ public function __construct() {
3535parent ::__construct ();
3636$ this ->addDescription ( 'Deletes all pages in the MediaWiki namespace ' .
3737' which were last edited by "MediaWiki default" ' );
38+ $ this ->addOption ( 'dry-run ' , 'Perform a dry run, delete nothing ' );
3839}
3940
4041public function execute () {
@@ -52,22 +53,31 @@ public function execute() {
5253);
5354
5455if ( $ dbr ->numRows ( $ res ) == 0 ) {
55- # No more messages left
56+ // No more messages left
5657$ this ->output ( "done. \n" );
58+ return ;
59+ }
5760
61+ $ dryrun = $ this ->hasOption ( 'dry-run ' );
62+ if ( $ dryrun ) {
63+ foreach ( $ res as $ row ) {
64+ $ title = Title::makeTitle ( $ row ->page_namespace , $ row ->page_title );
65+ $ this ->output ( "\n* [[ $ title]] " );
66+ }
67+ $ this ->output ( "\n\nRun again without --dry-run to delete these pages. \n" );
5868return ;
5969}
6070
61- # Deletions will be made by $user temporarly added to the bot group
62- # in order to hide it in RecentChanges.
71+ // Deletions will be made by $user temporarly added to the bot group
72+ // in order to hide it in RecentChanges.
6373$ user = User::newFromName ( 'MediaWiki default ' );
6474if ( !$ user ) {
6575$ this ->error ( "Invalid username " , true );
6676}
6777$ user ->addGroup ( 'bot ' );
6878$ wgUser = $ user ;
6979
70- # Handle deletion
80+ // Handle deletion
7181$ this ->output ( "\n...deleting old default messages (this may take a long time!)... " , 'msg ' );
7282$ dbw = $ this ->getDB ( DB_MASTER );
7383
0 commit comments