r107513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107512‎ | r107513 | r107514 >
Date:19:35, 28 December 2011
Author:ialex
Status:ok
Tags:
Comment:
* Use WikiPage instead of Article to call doDeleteArticle()
* Don't call DatabaseBase::commit() twice per deletion
* Some code refactoring
Modified paths:
  • /trunk/phase3/maintenance/deleteDefaultMessages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/deleteDefaultMessages.php
@@ -31,10 +31,8 @@
3232 }
3333
3434 public function execute() {
 35+ global $wgUser;
3536
36 - $user = 'MediaWiki default';
37 - $reason = 'No longer required';
38 -
3937 $this->output( "Checking existence of old default messages..." );
4038 $dbr = wfGetDB( DB_SLAVE );
4139 $res = $dbr->select( array( 'page', 'revision' ),
@@ -54,12 +52,12 @@
5553
5654 # Deletions will be made by $user temporarly added to the bot group
5755 # in order to hide it in RecentChanges.
58 - global $wgUser;
59 - $wgUser = User::newFromName( $user );
60 - if ( !$wgUser ) {
 56+ $user = User::newFromName( 'MediaWiki default' );
 57+ if ( !$user ) {
6158 $this->error( "Invalid username", true );
6259 }
63 - $wgUser->addGroup( 'bot' );
 60+ $user->addGroup( 'bot' );
 61+ $wgUser = $user;
6462
6563 # Handle deletion
6664 $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
@@ -69,9 +67,10 @@
7068 wfWaitForSlaves();
7169 $dbw->ping();
7270 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
73 - $article = new Article( $title );
 71+ $page = WikiPage::factory( $title );
7472 $dbw->begin();
75 - $article->doDeleteArticle( $reason );
 73+ $error = ''; // Passed by ref
 74+ $page->doDeleteArticle( 'No longer required', false, 0, false, $error, $user );
7675 $dbw->commit();
7776 }
7877

Status & tagging log