r89374 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89373‎ | r89374 | r89375 >
Date:00:53, 3 June 2011
Author:mah
Status:reverted (Comments)
Tags:
Comment:
Finish fix for bug #28172 (“wfGetDB called when it shouldn't be”).
Will now forward port to trunk
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
@@ -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() {
 2541+ function saveSettings( $dbw = null ) {
25422542 $this->load();
25432543 if ( wfReadOnly() ) { return; }
25442544 if ( 0 == $this->mId ) { return; }
25452545
25462546 $this->mTouched = self::newTouchedTimestamp();
25472547
2548 - $dbw = wfGetDB( DB_MASTER );
 2548+ if( $dbw === null ) $dbw = wfGetDB( DB_MASTER );
25492549 $dbw->update( 'user',
25502550 array( /* SET */
25512551 'user_name' => $this->mName,
@@ -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() {
 2578+ function idForName( $dbr = null ) {
25792579 $s = trim( $this->getName() );
25802580 if ( $s === '' ) return 0;
25812581
2582 - $dbr = wfGetDB( DB_SLAVE );
 2582+ if( $dbr == null ) $dbr = wfGetDB( DB_SLAVE );
25832583 $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
25842584 if ( $id === false ) {
25852585 $id = 0;
Index: branches/REL1_17/phase3/includes/installer/Installer.php
@@ -1382,7 +1382,7 @@
13831383 return Status::newFatal( 'config-admin-error-user', $name );
13841384 }
13851385
1386 - if ( $user->idForName() == 0 ) {
 1386+ if ( $user->idForName( $db ) == 0 ) {
13871387 $user->addToDatabase( $db );
13881388
13891389 try {

Follow-up revisions

RevisionCommit summaryAuthorDate
r89376Fix for bug #28172 (“wfGetDB called when it shouldn't be”)....mah01:06, 3 June 2011
r89738Revert r89374, r88936 backports.mah20:04, 8 June 2011
r89739Revert r89374, r88936mah20:13, 8 June 2011
r101880Bug 28172 - wfGetDB called when it shouldn't beoverlordq21:00, 3 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88936This needs to be forward-ported to trunk....mah21:49, 26 May 2011

Comments

#Comment by Tim Starling (talk | contribs)   04:37, 8 June 2011

Needs revert as per CR r88936.

Status & tagging log