Update cached user ID after user is added to the database
authorGergő Tisza <tgr.huwiki@gmail.com>
Thu, 19 Nov 2015 00:42:39 +0000 (16:42 -0800)
committerGergő Tisza <gtisza@wikimedia.org>
Fri, 20 Nov 2015 18:38:09 +0000 (18:38 +0000)
Bug: T119021
Change-Id: I5e0599d1d045b0389a7825fddc2b346e4cfd001d

includes/User.php

index b09e4e4..611f603 100644 (file)
@@ -2423,7 +2423,7 @@ class User implements IDBAccessObject {
         *  through the web interface.
         */
        private function setPasswordInternal( $str ) {
-               $id = self::idFromName( $this->getName() );
+               $id = self::idFromName( $this->getName(), self::READ_LATEST );
                if ( $id == 0 ) {
                        throw new LogicException( 'Cannot set a password for a user that is not in the database.' );
                }
@@ -3898,6 +3898,7 @@ class User implements IDBAccessObject {
                        return Status::newFatal( 'userexists' );
                }
                $this->mId = $dbw->insertId();
+               self::$idCacheByName[$this->mName] = $this->mId;
 
                // Clear instance cache other than user table data, which is already accurate
                $this->clearInstanceCache();