Fix undefined variable in User::setNewpassword
authorBryan Davis <bd808@wikimedia.org>
Tue, 20 Oct 2015 15:49:01 +0000 (09:49 -0600)
committerBryan Davis <bd808@wikimedia.org>
Tue, 20 Oct 2015 16:10:30 +0000 (10:10 -0600)
Follow up to I2c736ad to fix use of undefined `$id` variable.

Change-Id: I04bd9c1dd7e3e1e63b8008d02df91cfb1ad971a3

includes/User.php

index 0dfdfc4..6e52a1d 100644 (file)
@@ -2478,6 +2478,11 @@ class User implements IDBAccessObject {
         * @param bool $throttle If true, reset the throttle timestamp to the present
         */
        public function setNewpassword( $str, $throttle = true ) {
+               $id = $this->getId();
+               if ( $id == 0 ) {
+                       throw new LogicException( 'Cannot set new password for a user that is not in the database.' );
+               }
+
                $dbw = wfGetDB( DB_MASTER );
 
                $passwordFactory = new PasswordFactory();