Index: branches/REL1_17/phase3/includes/User.php |
— | — | @@ -2161,8 +2161,8 @@ |
2162 | 2162 | * This takes immediate effect. |
2163 | 2163 | * @param $group \string Name of the group to add |
2164 | 2164 | */ |
2165 | | - function addGroup( $group ) { |
2166 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2165 | + function addGroup( $group, $dbw = null ) { |
| 2166 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
2167 | 2167 | if( $this->getId() ) { |
2168 | 2168 | $dbw->insert( 'user_groups', |
2169 | 2169 | array( |
— | — | @@ -2563,7 +2563,7 @@ |
2564 | 2564 | ), __METHOD__ |
2565 | 2565 | ); |
2566 | 2566 | |
2567 | | - $this->saveOptions(); |
| 2567 | + $this->saveOptions( $dbw ); |
2568 | 2568 | |
2569 | 2569 | wfRunHooks( 'UserSaveSettings', array( $this ) ); |
2570 | 2570 | $this->clearSharedCache(); |
— | — | @@ -2640,9 +2640,9 @@ |
2641 | 2641 | /** |
2642 | 2642 | * Add this existing user object to the database |
2643 | 2643 | */ |
2644 | | - function addToDatabase() { |
| 2644 | + function addToDatabase( $dbw = null ) { |
2645 | 2645 | $this->load(); |
2646 | | - $dbw = wfGetDB( DB_MASTER ); |
| 2646 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
2647 | 2647 | $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' ); |
2648 | 2648 | $dbw->insert( 'user', |
2649 | 2649 | array( |
— | — | @@ -2665,7 +2665,7 @@ |
2666 | 2666 | // Clear instance cache other than user table data, which is already accurate |
2667 | 2667 | $this->clearInstanceCache(); |
2668 | 2668 | |
2669 | | - $this->saveOptions(); |
| 2669 | + $this->saveOptions( $dbw ); |
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | /** |
— | — | @@ -3683,13 +3683,13 @@ |
3684 | 3684 | wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) ); |
3685 | 3685 | } |
3686 | 3686 | |
3687 | | - protected function saveOptions() { |
| 3687 | + protected function saveOptions( $dbw = null ) { |
3688 | 3688 | global $wgAllowPrefChange; |
3689 | 3689 | |
3690 | 3690 | $extuser = ExternalUser::newFromUser( $this ); |
3691 | 3691 | |
3692 | 3692 | $this->loadOptions(); |
3693 | | - $dbw = wfGetDB( DB_MASTER ); |
| 3693 | + if( $dbw === null ) $dbw = wfGetDB( DB_MASTER ); |
3694 | 3694 | |
3695 | 3695 | $insert_rows = array(); |
3696 | 3696 | |
Index: branches/REL1_17/phase3/includes/installer/Installer.php |
— | — | @@ -1370,6 +1370,12 @@ |
1371 | 1371 | protected function createSysop() { |
1372 | 1372 | $name = $this->getVar( '_AdminName' ); |
1373 | 1373 | $user = User::newFromName( $name ); |
| 1374 | + $status = $this->getDBInstaller()->getConnection(); |
| 1375 | + if( $status->isOK() ) { |
| 1376 | + $db = $status->value; |
| 1377 | + } else { |
| 1378 | + return Status::newFatal( 'config-admin-error-user', $name ); |
| 1379 | + } |
1374 | 1380 | |
1375 | 1381 | if ( !$user ) { |
1376 | 1382 | // We should've validated this earlier anyway! |
— | — | @@ -1377,7 +1383,7 @@ |
1378 | 1384 | } |
1379 | 1385 | |
1380 | 1386 | if ( $user->idForName() == 0 ) { |
1381 | | - $user->addToDatabase(); |
| 1387 | + $user->addToDatabase( $db ); |
1382 | 1388 | |
1383 | 1389 | try { |
1384 | 1390 | $user->setPassword( $this->getVar( '_AdminPassword' ) ); |
— | — | @@ -1385,12 +1391,12 @@ |
1386 | 1392 | return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() ); |
1387 | 1393 | } |
1388 | 1394 | |
1389 | | - $user->addGroup( 'sysop' ); |
1390 | | - $user->addGroup( 'bureaucrat' ); |
| 1395 | + $user->addGroup( 'sysop', $db ); |
| 1396 | + $user->addGroup( 'bureaucrat', $db ); |
1391 | 1397 | if( $this->getVar( '_AdminEmail' ) ) { |
1392 | 1398 | $user->setEmail( $this->getVar( '_AdminEmail' ) ); |
1393 | 1399 | } |
1394 | | - $user->saveSettings(); |
| 1400 | + $user->saveSettings( $db ); |
1395 | 1401 | |
1396 | 1402 | // Update user count |
1397 | 1403 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |