I423f09f added this call in an attempt to speed things up. However,
User::checkPassword() was deprecated in I2c736ad7, and the call causes
some tests to fail when $wgDisableAuthManager is false.
Since this is trying to determine whether the user_password column in
the user table needs updating for the unit test, let's test that
directly instead of the much-more-complicated User::checkPassword().
Change-Id: I410de706f9074edea3f3988769a3e99231d8dca3
throw new MWException( "Passed User has not been added to the database yet!" );
}
throw new MWException( "Passed User has not been added to the database yet!" );
}
- if ( $user->checkPassword( $password ) === true ) {
- return; // Nothing to do.
- }
-
- $passwordFactory = new PasswordFactory();
- $passwordFactory->init( RequestContext::getMain()->getConfig() );
- $passwordHash = $passwordFactory->newFromPlaintext( $password );
- wfGetDB( DB_MASTER )->update(
+ $dbw = wfGetDB( DB_MASTER );
+ $row = $dbw->selectRow(
- [ 'user_password' => $passwordHash->toString() ],
[ 'user_id' => $user->getId() ],
__METHOD__
);
[ 'user_id' => $user->getId() ],
__METHOD__
);
+ if ( !$row ) {
+ throw new MWException( "Passed User has an ID but is not in the database?" );
+ }
+
+ $passwordFactory = new PasswordFactory();
+ $passwordFactory->init( RequestContext::getMain()->getConfig() );
+ if ( !$passwordFactory->newFromCiphertext( $row->user_password )->equals( $password ) ) {
+ $passwordHash = $passwordFactory->newFromPlaintext( $password );
+ $dbw->update(
+ 'user',
+ [ 'user_password' => $passwordHash->toString() ],
+ [ 'user_id' => $user->getId() ],
+ __METHOD__
+ );
+ }