Hoo man has uploaded a new change for review.

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

Change subject: Only test passwords once in CentralAuthUser::prepareMigration
......................................................................

Only test passwords once in CentralAuthUser::prepareMigration

As PHP tends to run out of memory in the second check...

Bug: T78727
Change-Id: I2e396db410db9a1b79ecb33507c9ca2c85f9cbbb
(cherry picked from commit e9e5e785678e5a06f4fa0064a58d83eb307df3c9)
---
M includes/CentralAuthUser.php
1 file changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/74/184374/1

diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index a9b8682..4594117 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -773,17 +773,20 @@
                        $passingMail[$this->mEmail] = true;
                }
 
-               $accountPasswords = array();
+               $passwordConfirmed = array();
                // If we've got an authenticated password to work with, we can
                // also assume their email addresses are useful for this 
purpose...
                if ( $passwords ) {
                        foreach ( $migrationSet as $wiki => $local ) {
-                               // Store the password object, so that we only 
have to compute it once
-                               $accountPasswords[$wiki] = 
$this->getPasswordFromString( $local['password'],  $local['id'] );
+                               // Test passwords only once here as comparing 
hashes is very expensive
+                               $passwordConfirmed[$wiki] = $this->matchHashes(
+                                       $passwords,
+                                       $this->getPasswordFromString( 
$local['password'],  $local['id'] )
+                               );
 
                                if ( $local['email'] != ''
                                        && $local['emailAuthenticated']
-                                       && $this->matchHashes( $passwords, 
$accountPasswords[$wiki] ) ) {
+                                       && $passwordConfirmed[$wiki] ) {
                                        $passingMail[$local['email']] = true;
                                }
                        }
@@ -795,7 +798,7 @@
                        if ( $wiki == $this->mHomeWiki ) {
                                // Primary account holder... duh
                                $method = 'primary';
-                       } elseif ( $passwords && $this->matchHashes( 
$passwords, $accountPasswords[$wiki] ) ) {
+                       } elseif ( isset( $passwordConfirmed[$wiki] ) && 
$passwordConfirmed[$wiki] ) {
                                // Matches the pre-authenticated password, yay!
                                $method = 'password';
                        } elseif ( $local['emailAuthenticated'] && isset( 
$passingMail[$local['email']] ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e396db410db9a1b79ecb33507c9ca2c85f9cbbb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.25wmf14
Gerrit-Owner: Hoo man <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to