r89739 MediaWiki - Code Review archive

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

Diff [purge]

Index: branches/REL1_17/phase3/includes/User.php
@@ -2162,8 +2162,8 @@
21632163 * This takes immediate effect.
21642164 * @param $group \string Name of the group to add
21652165 */
2166 - function addGroup( $group, $dbw = null ) {
2167 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 2166+ function addGroup( $group ) {
 2167+ $dbw = wfGetDB( DB_MASTER );
21682168 if( $this->getId() ) {
21692169 $dbw->insert( 'user_groups',
21702170 array(
@@ -2537,14 +2537,14 @@
25382538 * Save this user's settings into the database.
25392539 * @todo Only rarely do all these fields need to be set!
25402540 */
2541 - function saveSettings( $dbw = null ) {
 2541+ function saveSettings() {
25422542 $this->load();
25432543 if ( wfReadOnly() ) { return; }
25442544 if ( 0 == $this->mId ) { return; }
25452545
25462546 $this->mTouched = self::newTouchedTimestamp();
25472547
2548 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 2548+ $dbw = wfGetDB( DB_MASTER );
25492549 $dbw->update( 'user',
25502550 array( /* SET */
25512551 'user_name' => $this->mName,
@@ -2564,7 +2564,7 @@
25652565 ), __METHOD__
25662566 );
25672567
2568 - $this->saveOptions( $dbw );
 2568+ $this->saveOptions();
25692569
25702570 wfRunHooks( 'UserSaveSettings', array( $this ) );
25712571 $this->clearSharedCache();
@@ -2574,11 +2574,11 @@
25752575 /**
25762576 * If only this user's username is known, and it exists, return the user ID.
25772577 */
2578 - function idForName( $dbr = null ) {
 2578+ function idForName() {
25792579 $s = trim( $this->getName() );
25802580 if ( $s === '' ) return 0;
25812581
2582 - if( $dbr == null ) $dbr = wfGetDB( DB_SLAVE );
 2582+ $dbr = wfGetDB( DB_SLAVE );
25832583 $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
25842584 if ( $id === false ) {
25852585 $id = 0;
@@ -2641,9 +2641,9 @@
26422642 /**
26432643 * Add this existing user object to the database
26442644 */
2645 - function addToDatabase( $dbw = null ) {
 2645+ function addToDatabase() {
26462646 $this->load();
2647 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 2647+ $dbw = wfGetDB( DB_MASTER );
26482648 $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
26492649 $dbw->insert( 'user',
26502650 array(
@@ -2666,7 +2666,7 @@
26672667 // Clear instance cache other than user table data, which is already accurate
26682668 $this->clearInstanceCache();
26692669
2670 - $this->saveOptions( $dbw );
 2670+ $this->saveOptions();
26712671 }
26722672
26732673 /**
@@ -3684,13 +3684,13 @@
36853685 wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
36863686 }
36873687
3688 - protected function saveOptions( $dbw = null ) {
 3688+ protected function saveOptions() {
36893689 global $wgAllowPrefChange;
36903690
36913691 $extuser = ExternalUser::newFromUser( $this );
36923692
36933693 $this->loadOptions();
3694 - if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
 3694+ $dbw = wfGetDB( DB_MASTER );
36953695
36963696 $insert_rows = array();
36973697
Index: branches/REL1_17/phase3/includes/installer/Installer.php
@@ -961,7 +961,7 @@
962962 $this->showMessage( 'config-uploads-not-safe', $dir );
963963 }
964964 }
965 -
 965+
966966 /**
967967 * Checks if suhosin.get.max_value_length is set, and if so, sets
968968 * $wgResourceLoaderMaxQueryLength to that value in the generated
@@ -1393,20 +1393,14 @@
13941394 protected function createSysop() {
13951395 $name = $this->getVar( '_AdminName' );
13961396 $user = User::newFromName( $name );
1397 - $status = $this->getDBInstaller()->getConnection();
1398 - if( $status->isOK() ) {
1399 - $db = $status->value;
1400 - } else {
1401 - return Status::newFatal( 'config-admin-error-user', $name );
1402 - }
14031397
14041398 if ( !$user ) {
14051399 // We should've validated this earlier anyway!
14061400 return Status::newFatal( 'config-admin-error-user', $name );
14071401 }
14081402
1409 - if ( $user->idForName( $db ) == 0 ) {
1410 - $user->addToDatabase( $db );
 1403+ if ( $user->idForName() == 0 ) {
 1404+ $user->addToDatabase();
14111405
14121406 try {
14131407 $user->setPassword( $this->getVar( '_AdminPassword' ) );
@@ -1414,12 +1408,12 @@
14151409 return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
14161410 }
14171411
1418 - $user->addGroup( 'sysop', $db );
1419 - $user->addGroup( 'bureaucrat', $db );
 1412+ $user->addGroup( 'sysop' );
 1413+ $user->addGroup( 'bureaucrat' );
14201414 if( $this->getVar( '_AdminEmail' ) ) {
14211415 $user->setEmail( $this->getVar( '_AdminEmail' ) );
14221416 }
1423 - $user->saveSettings( $db );
 1417+ $user->saveSettings();
14241418
14251419 // Update user count
14261420 $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

Status & tagging log