Revert r89374, r88936 backports.
authorMark A. Hershberger <mah@users.mediawiki.org>
Wed, 8 Jun 2011 20:04:45 +0000 (20:04 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Wed, 8 Jun 2011 20:04:45 +0000 (20:04 +0000)
includes/User.php
includes/installer/Installer.php

index 1ebc3a4..f4bf1eb 100644 (file)
@@ -2228,9 +2228,9 @@ class User {
         * 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(
@@ -2601,14 +2601,14 @@ class User {
         * 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,
@@ -2628,7 +2628,7 @@ class User {
                        ), __METHOD__
                );
 
-               $this->saveOptions( $dbw );
+               $this->saveOptions();
 
                wfRunHooks( 'UserSaveSettings', array( $this ) );
                $this->clearSharedCache();
@@ -2639,11 +2639,11 @@ class User {
         * 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;
@@ -2706,9 +2706,9 @@ class User {
        /**
         * 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(
@@ -2731,7 +2731,7 @@ class User {
                // Clear instance cache other than user table data, which is already accurate
                $this->clearInstanceCache();
 
-               $this->saveOptions( $dbw );
+               $this->saveOptions();
        }
 
        /**
@@ -3776,13 +3776,13 @@ class User {
                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();
 
index 646644d..008b071 100644 (file)
@@ -1406,20 +1406,14 @@ abstract class Installer {
        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' ) );
@@ -1427,12 +1421,12 @@ abstract class Installer {
                                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 );