mDescription = "Deletes all pages in the MediaWiki namespace" . " which were last edited by \"MediaWiki default\""; } public function execute() { $user = 'MediaWiki default'; $reason = 'No longer required'; $this->output( "Checking existence of old default messages..." ); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( array( 'page', 'revision' ), array( 'page_namespace', 'page_title' ), array( 'page_namespace' => NS_MEDIAWIKI, 'page_latest=rev_id', 'rev_user_text' => 'MediaWiki default', ) ); if( $dbr->numRows( $res ) == 0 ) { # No more messages left $this->output( "done.\n" ); return; } # Deletions will be made by $user temporarly added to the bot group # in order to hide it in RecentChanges. global $wgUser; $wgUser = User::newFromName( $user ); $wgUser->addGroup( 'bot' ); # Handle deletion $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' ); $dbw = wfGetDB( DB_MASTER ); foreach ( $res as $row ) { if ( function_exists( 'wfWaitForSlaves' ) ) { wfWaitForSlaves( 5 ); } $dbw->ping(); $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $article = new Article( $title ); $dbw->begin(); $article->doDeleteArticle( $reason ); $dbw->commit(); } $this->output( 'done!', 'msg' ); } } $maintClass = "DeleteDefaultMessages"; require_once( RUN_MAINTENANCE_IF_MAIN );