From 9a362d64c86989837f9a0755abc7c5a78457ca78 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 18 Nov 2013 16:04:09 +0100 Subject: [PATCH] Allow null to be passed to User::setNewPassword() This allows the temporary password to be cleared. This methods now behaves the same as User::setInternalPassword() with that value. Bug: 57075 Change-Id: I2c446864c7eb591dcb64e5971bc9989950715d15 --- includes/User.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/User.php b/includes/User.php index c86b966ffe..224626b928 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2173,14 +2173,21 @@ class User { /** * Set the password for a password reminder or new account email * - * @param string $str New password to set + * @param $str New password to set or null to set an invalid + * password hash meaning that the user will not be able to use it * @param bool $throttle If true, reset the throttle timestamp to the present */ public function setNewpassword( $str, $throttle = true ) { $this->load(); - $this->mNewpassword = self::crypt( $str ); - if ( $throttle ) { - $this->mNewpassTime = wfTimestampNow(); + + if ( $str === null ) { + $this->mNewpassword = ''; + $this->mNewpassTime = null; + } else { + $this->mNewpassword = self::crypt( $str ); + if ( $throttle ) { + $this->mNewpassTime = wfTimestampNow(); + } } } -- 2.20.1