Index: trunk/phase3/includes/User.php |
— | — | @@ -2230,9 +2230,9 @@ |
2231 | 2231 | * This takes immediate effect. |
2232 | 2232 | * @param $group String Name of the group to add |
2233 | 2233 | */ |
2234 | | - function addGroup( $group ) { |
| 2234 | + function addGroup( $group, $dbw = null ) { |
2235 | 2235 | if( wfRunHooks( 'UserAddGroup', array( &$this, &$group ) ) ) { |
2236 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2236 | + if( $dbw == null ) $dbw = wfGetDB( DB_MASTER ); |
2237 | 2237 | if( $this->getId() ) { |
2238 | 2238 | $dbw->insert( 'user_groups', |
2239 | 2239 | array( |
— | — | @@ -2603,14 +2603,14 @@ |
2604 | 2604 | * Save this user's settings into the database. |
2605 | 2605 | * @todo Only rarely do all these fields need to be set! |
2606 | 2606 | */ |
2607 | | - function saveSettings() { |
| 2607 | + function saveSettings( $dbw = null ) { |
2608 | 2608 | $this->load(); |
2609 | 2609 | if ( wfReadOnly() ) { return; } |
2610 | 2610 | if ( 0 == $this->mId ) { return; } |
2611 | 2611 | |
2612 | 2612 | $this->mTouched = self::newTouchedTimestamp(); |
2613 | 2613 | |
2614 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2614 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
2615 | 2615 | $dbw->update( 'user', |
2616 | 2616 | array( /* SET */ |
2617 | 2617 | 'user_name' => $this->mName, |
— | — | @@ -2630,7 +2630,7 @@ |
2631 | 2631 | ), __METHOD__ |
2632 | 2632 | ); |
2633 | 2633 | |
2634 | | - $this->saveOptions(); |
| 2634 | + $this->saveOptions( $dbw ); |
2635 | 2635 | |
2636 | 2636 | wfRunHooks( 'UserSaveSettings', array( $this ) ); |
2637 | 2637 | $this->clearSharedCache(); |
— | — | @@ -2641,11 +2641,11 @@ |
2642 | 2642 | * If only this user's username is known, and it exists, return the user ID. |
2643 | 2643 | * @return Int |
2644 | 2644 | */ |
2645 | | - function idForName() { |
| 2645 | + function idForName( $dbr = null ) { |
2646 | 2646 | $s = trim( $this->getName() ); |
2647 | 2647 | if ( $s === '' ) return 0; |
2648 | 2648 | |
2649 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 2649 | + if( $dbr == null ) $dbr = wfGetDB( DB_SLAVE ); |
2650 | 2650 | $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ ); |
2651 | 2651 | if ( $id === false ) { |
2652 | 2652 | $id = 0; |
— | — | @@ -2708,9 +2708,9 @@ |
2709 | 2709 | /** |
2710 | 2710 | * Add this existing user object to the database |
2711 | 2711 | */ |
2712 | | - function addToDatabase() { |
| 2712 | + function addToDatabase( $dbw = null ) { |
2713 | 2713 | $this->load(); |
2714 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2714 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
2715 | 2715 | $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' ); |
2716 | 2716 | $dbw->insert( 'user', |
2717 | 2717 | array( |
— | — | @@ -2733,7 +2733,7 @@ |
2734 | 2734 | // Clear instance cache other than user table data, which is already accurate |
2735 | 2735 | $this->clearInstanceCache(); |
2736 | 2736 | |
2737 | | - $this->saveOptions(); |
| 2737 | + $this->saveOptions( $dbw ); |
2738 | 2738 | } |
2739 | 2739 | |
2740 | 2740 | /** |
— | — | @@ -3778,13 +3778,13 @@ |
3779 | 3779 | wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) ); |
3780 | 3780 | } |
3781 | 3781 | |
3782 | | - protected function saveOptions() { |
| 3782 | + protected function saveOptions( $dbw = null ) { |
3783 | 3783 | global $wgAllowPrefChange; |
3784 | 3784 | |
3785 | 3785 | $extuser = ExternalUser::newFromUser( $this ); |
3786 | 3786 | |
3787 | 3787 | $this->loadOptions(); |
3788 | | - $dbw = wfGetDB( DB_MASTER ); |
| 3788 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
3789 | 3789 | |
3790 | 3790 | $insert_rows = array(); |
3791 | 3791 | |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -1407,14 +1407,20 @@ |
1408 | 1408 | protected function createSysop() { |
1409 | 1409 | $name = $this->getVar( '_AdminName' ); |
1410 | 1410 | $user = User::newFromName( $name ); |
| 1411 | + $status = $this->getDBInstaller()->getConnection(); |
| 1412 | + if( $status->isOK() ) { |
| 1413 | + $db = $status->value; |
| 1414 | + } else { |
| 1415 | + return Status::newFatal( 'config-admin-error-user', $name ); |
| 1416 | + } |
1411 | 1417 | |
1412 | 1418 | if ( !$user ) { |
1413 | 1419 | // We should've validated this earlier anyway! |
1414 | 1420 | return Status::newFatal( 'config-admin-error-user', $name ); |
1415 | 1421 | } |
1416 | 1422 | |
1417 | | - if ( $user->idForName() == 0 ) { |
1418 | | - $user->addToDatabase(); |
| 1423 | + if ( $user->idForName( $db ) == 0 ) { |
| 1424 | + $user->addToDatabase( $db ); |
1419 | 1425 | |
1420 | 1426 | try { |
1421 | 1427 | $user->setPassword( $this->getVar( '_AdminPassword' ) ); |
— | — | @@ -1422,12 +1428,12 @@ |
1423 | 1429 | return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() ); |
1424 | 1430 | } |
1425 | 1431 | |
1426 | | - $user->addGroup( 'sysop' ); |
1427 | | - $user->addGroup( 'bureaucrat' ); |
| 1432 | + $user->addGroup( 'sysop', $db ); |
| 1433 | + $user->addGroup( 'bureaucrat', $db ); |
1428 | 1434 | if( $this->getVar( '_AdminEmail' ) ) { |
1429 | 1435 | $user->setEmail( $this->getVar( '_AdminEmail' ) ); |
1430 | 1436 | } |
1431 | | - $user->saveSettings(); |
| 1437 | + $user->saveSettings( $db ); |
1432 | 1438 | |
1433 | 1439 | // Update user count |
1434 | 1440 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
— | — | @@ -1461,7 +1467,7 @@ |
1462 | 1468 | array( 'method' => 'POST', 'postData' => $params ) )->execute(); |
1463 | 1469 | if( !$res->isOK() ) { |
1464 | 1470 | $s->warning( 'config-install-subscribe-fail', $res->getMessage() ); |
1465 | | - } |
| 1471 | + } |
1466 | 1472 | } |
1467 | 1473 | |
1468 | 1474 | /** |