* This takes immediate effect.
* @param $group String Name of the group to add
*/
- function addGroup( $group, $dbw = null ) {
+ function addGroup( $group ) {
if( wfRunHooks( 'UserAddGroup', array( &$this, &$group ) ) ) {
- if( $dbw == null ) $dbw = wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );
if( $this->getId() ) {
$dbw->insert( 'user_groups',
array(
* Save this user's settings into the database.
* @todo Only rarely do all these fields need to be set!
*/
- function saveSettings( $dbw = null ) {
+ function saveSettings() {
$this->load();
if ( wfReadOnly() ) { return; }
if ( 0 == $this->mId ) { return; }
$this->mTouched = self::newTouchedTimestamp();
- if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );
$dbw->update( 'user',
array( /* SET */
'user_name' => $this->mName,
), __METHOD__
);
- $this->saveOptions( $dbw );
+ $this->saveOptions();
wfRunHooks( 'UserSaveSettings', array( $this ) );
$this->clearSharedCache();
* If only this user's username is known, and it exists, return the user ID.
* @return Int
*/
- function idForName( $dbr = null ) {
+ function idForName() {
$s = trim( $this->getName() );
if ( $s === '' ) return 0;
- if( $dbr == null ) $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
if ( $id === false ) {
$id = 0;
/**
* Add this existing user object to the database
*/
- function addToDatabase( $dbw = null ) {
+ function addToDatabase() {
$this->load();
- if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );
$seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
$dbw->insert( 'user',
array(
// Clear instance cache other than user table data, which is already accurate
$this->clearInstanceCache();
- $this->saveOptions( $dbw );
+ $this->saveOptions();
}
/**
wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
}
- protected function saveOptions( $dbw = null ) {
+ protected function saveOptions() {
global $wgAllowPrefChange;
$extuser = ExternalUser::newFromUser( $this );
$this->loadOptions();
- if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );
$insert_rows = array();
protected function createSysop() {
$name = $this->getVar( '_AdminName' );
$user = User::newFromName( $name );
- $status = $this->getDBInstaller()->getConnection();
- if( $status->isOK() ) {
- $db = $status->value;
- } else {
- return Status::newFatal( 'config-admin-error-user', $name );
- }
if ( !$user ) {
// We should've validated this earlier anyway!
return Status::newFatal( 'config-admin-error-user', $name );
}
- if ( $user->idForName( $db ) == 0 ) {
- $user->addToDatabase( $db );
+ if ( $user->idForName() == 0 ) {
+ $user->addToDatabase();
try {
$user->setPassword( $this->getVar( '_AdminPassword' ) );
return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
}
- $user->addGroup( 'sysop', $db );
- $user->addGroup( 'bureaucrat', $db );
+ $user->addGroup( 'sysop' );
+ $user->addGroup( 'bureaucrat' );
if( $this->getVar( '_AdminEmail' ) ) {
$user->setEmail( $this->getVar( '_AdminEmail' ) );
}
- $user->saveSettings( $db );
+ $user->saveSettings();
// Update user count
$ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );