r89738 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89737‎ | r89738 | r89739 >
Date:20:04, 8 June 2011
Author:mah
Status:ok
Tags:
Comment:
Revert r89374, r88936 backports.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2228,9 +2228,9 @@
22292229 * This takes immediate effect.
22302230 * @param $group String Name of the group to add
22312231 */
2232 - function addGroup( $group, $dbw = null ) {
 2232+ function addGroup( $group ) {
22332233 if( wfRunHooks( 'UserAddGroup', array( &$this, &$group ) ) ) {
2234 - if( $dbw == null ) $dbw = wfGetDB( DB_MASTER );
 2234+ $dbw = wfGetDB( DB_MASTER );
22352235 if( $this->getId() ) {
22362236 $dbw->insert( 'user_groups',
22372237 array(
@@ -2601,14 +2601,14 @@
26022602 * Save this user's settings into the database.
26032603 * @todo Only rarely do all these fields need to be set!
26042604 */
2605 - function saveSettings( $dbw = null ) {
 2605+ function saveSettings() {
26062606 $this->load();
26072607 if ( wfReadOnly() ) { return; }
26082608 if ( 0 == $this->mId ) { return; }
26092609
26102610 $this->mTouched = self::newTouchedTimestamp();
26112611
2612 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 2612+ $dbw = wfGetDB( DB_MASTER );
26132613 $dbw->update( 'user',
26142614 array( /* SET */
26152615 'user_name' => $this->mName,
@@ -2628,7 +2628,7 @@
26292629 ), __METHOD__
26302630 );
26312631
2632 - $this->saveOptions( $dbw );
 2632+ $this->saveOptions();
26332633
26342634 wfRunHooks( 'UserSaveSettings', array( $this ) );
26352635 $this->clearSharedCache();
@@ -2639,11 +2639,11 @@
26402640 * If only this user's username is known, and it exists, return the user ID.
26412641 * @return Int
26422642 */
2643 - function idForName( $dbr = null ) {
 2643+ function idForName() {
26442644 $s = trim( $this->getName() );
26452645 if ( $s === '' ) return 0;
26462646
2647 - if( $dbr == null ) $dbr = wfGetDB( DB_SLAVE );
 2647+ $dbr = wfGetDB( DB_SLAVE );
26482648 $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
26492649 if ( $id === false ) {
26502650 $id = 0;
@@ -2706,9 +2706,9 @@
27072707 /**
27082708 * Add this existing user object to the database
27092709 */
2710 - function addToDatabase( $dbw = null ) {
 2710+ function addToDatabase() {
27112711 $this->load();
2712 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 2712+ $dbw = wfGetDB( DB_MASTER );
27132713 $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
27142714 $dbw->insert( 'user',
27152715 array(
@@ -2731,7 +2731,7 @@
27322732 // Clear instance cache other than user table data, which is already accurate
27332733 $this->clearInstanceCache();
27342734
2735 - $this->saveOptions( $dbw );
 2735+ $this->saveOptions();
27362736 }
27372737
27382738 /**
@@ -3776,13 +3776,13 @@
37773777 wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
37783778 }
37793779
3780 - protected function saveOptions( $dbw = null ) {
 3780+ protected function saveOptions() {
37813781 global $wgAllowPrefChange;
37823782
37833783 $extuser = ExternalUser::newFromUser( $this );
37843784
37853785 $this->loadOptions();
3786 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 3786+ $dbw = wfGetDB( DB_MASTER );
37873787
37883788 $insert_rows = array();
37893789
Index: trunk/phase3/includes/installer/Installer.php
@@ -1406,20 +1406,14 @@
14071407 protected function createSysop() {
14081408 $name = $this->getVar( '_AdminName' );
14091409 $user = User::newFromName( $name );
1410 - $status = $this->getDBInstaller()->getConnection();
1411 - if( $status->isOK() ) {
1412 - $db = $status->value;
1413 - } else {
1414 - return Status::newFatal( 'config-admin-error-user', $name );
1415 - }
14161410
14171411 if ( !$user ) {
14181412 // We should've validated this earlier anyway!
14191413 return Status::newFatal( 'config-admin-error-user', $name );
14201414 }
14211415
1422 - if ( $user->idForName( $db ) == 0 ) {
1423 - $user->addToDatabase( $db );
 1416+ if ( $user->idForName() == 0 ) {
 1417+ $user->addToDatabase();
14241418
14251419 try {
14261420 $user->setPassword( $this->getVar( '_AdminPassword' ) );
@@ -1427,12 +1421,12 @@
14281422 return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
14291423 }
14301424
1431 - $user->addGroup( 'sysop', $db );
1432 - $user->addGroup( 'bureaucrat', $db );
 1425+ $user->addGroup( 'sysop' );
 1426+ $user->addGroup( 'bureaucrat' );
14331427 if( $this->getVar( '_AdminEmail' ) ) {
14341428 $user->setEmail( $this->getVar( '_AdminEmail' ) );
14351429 }
1436 - $user->saveSettings( $db );
 1430+ $user->saveSettings();
14371431
14381432 // Update user count
14391433 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88936This needs to be forward-ported to trunk....mah21:49, 26 May 2011
r89374Finish fix for bug #28172 (“wfGetDB called when it shouldn't be”)....mah00:53, 3 June 2011
r89376Fix for bug #28172 (“wfGetDB called when it shouldn't be”)....mah01:06, 3 June 2011

Status & tagging log