* ensure 'MediaWiki default' user is a bot when running batch deletion of mediawiki entries, so they don't clutter up RC

* as paranoia, don't insert a groups record into the database if User::addGroup() ends up run on a non-existing user
This commit is contained in:
Brion Vibber 2007-01-07 11:21:41 +00:00
parent 803b3c07f8
commit c95ec8d74e
2 changed files with 11 additions and 7 deletions

View file

@ -1575,13 +1575,15 @@ class User {
function addGroup( $group ) {
$this->load();
$dbw =& wfGetDB( DB_MASTER );
$dbw->insert( 'user_groups',
array(
'ug_user' => $this->getID(),
'ug_group' => $group,
),
'User::addGroup',
array( 'IGNORE' ) );
if( $this->getId() ) {
$dbw->insert( 'user_groups',
array(
'ug_user' => $this->getID(),
'ug_group' => $group,
),
'User::addGroup',
array( 'IGNORE' ) );
}
$this->mGroups[] = $group;
$this->mRights = User::getGroupPermissions( $this->getEffectiveGroups( true ) );

View file

@ -16,6 +16,8 @@ function deleteDefaultMessages() {
global $wgUser;
$wgUser = User::newFromName( $user );
$wgUser->addGroup( 'bot' );
$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select( array( 'page', 'revision' ),
array( 'page_namespace', 'page_title' ),