aboutsummaryrefslogtreecommitdiffstats
path: root/includes/password/PasswordFactory.php
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2014-09-29 14:40:51 -0400
committerOri.livneh <ori@wikimedia.org>2014-09-29 21:42:33 +0000
commit4dc1f5a1759bdf392504f4901748175b46f59a7e (patch)
treebb53227fde048484b8755710351659c935dd1bcc /includes/password/PasswordFactory.php
parent3c8869569b034d1c62a1fc2fa772b5ebb8301d53 (diff)
downloadmediawikicore-4dc1f5a1759bdf392504f4901748175b46f59a7e.tar.gz
mediawikicore-4dc1f5a1759bdf392504f4901748175b46f59a7e.zip
PasswordFactory::newFromPlaintext( null ) needs to work
Various code passes null around to mean "an invalid password". It shouldn't all have to test for null and specially handle that. This also fixes a codepath where User::$mNewpassword could get set to an empty string rather than a password object, which would cause problems later when anything else tries to use it. Bug: 71421 Change-Id: Ib5f94b52c07e7dba89328b98fb43c86db95ee09f
Diffstat (limited to 'includes/password/PasswordFactory.php')
-rw-r--r--includes/password/PasswordFactory.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/includes/password/PasswordFactory.php b/includes/password/PasswordFactory.php
index 3b4ebb1af89b..48d6866926bc 100644
--- a/includes/password/PasswordFactory.php
+++ b/includes/password/PasswordFactory.php
@@ -141,11 +141,15 @@ final class PasswordFactory {
* If no existing object is given, make a new default object. If one is given, clone that
* object. Then pass the plaintext to Password::crypt().
*
- * @param string $password Plaintext password
+ * @param string|null $password Plaintext password, or null for an invalid password
* @param Password|null $existing Optional existing hash to get options from
* @return Password
*/
public function newFromPlaintext( $password, Password $existing = null ) {
+ if ( $password === null ) {
+ return new InvalidPassword( $this, array( 'type' => '' ), null );
+ }
+
if ( $existing === null ) {
$config = $this->types[$this->default];
$obj = new $config['class']( $this, $config );