Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200325

Change subject: Made User::loadPasswords generally use DB_SLAVE
......................................................................

Made User::loadPasswords generally use DB_SLAVE

Change-Id: I0a8bdab720c19fe3fc2381799ae2e90ff09bb4cf
---
M includes/User.php
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/25/200325/1

diff --git a/includes/User.php b/includes/User.php
index 78693c1..b732ed6 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -1365,7 +1365,12 @@
         */
        private function loadPasswords() {
                if ( $this->getId() !== 0 && ( $this->mPassword === null || 
$this->mNewpassword === null ) ) {
-                       $this->loadFromRow( wfGetDB( DB_MASTER )->selectRow(
+                       $timestampRecent = microtime( true ) - 10; // slave lag 
fudge
+                       $db = ( $this->getTouched() >= $timestampRecent )
+                               ? wfGetDB( DB_MASTER )
+                               : wfGetDB( DB_SLAVE );
+
+                       $this->loadFromRow( $db->selectRow(
                                        'user',
                                        array( 'user_password', 
'user_newpassword', 'user_newpass_time', 'user_password_expires' ),
                                        array( 'user_id' => $this->getId() ),
@@ -2258,6 +2263,7 @@
                                }
                        } );
                        $this->clearSharedCache();
+                       $this->touch(); // update cache immediately for lag 
checks
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/200325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a8bdab720c19fe3fc2381799ae2e90ff09bb4cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to