From: Roan Kattouw Date: Wed, 31 Oct 2018 22:38:07 +0000 (-0700) Subject: User: Don't fail mysteriously when passing a User object to idFromName() X-Git-Tag: 1.34.0-rc.0~3597^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=614dceed00bea7268bc3a2ddcd776e693ddb4b4d;p=lhc%2Fweb%2Fwiklou.git User: Don't fail mysteriously when passing a User object to idFromName() If $name is a User object, some code magically works because the object gets converted to a string, but other code blows up because objects aren't valid array keys. Prevent this from happening by explicitly forcing $name to be a string. Bug: T208469 Change-Id: Icc9ebec93d18609605e2633ccd23b90478e05e51 --- diff --git a/includes/user/User.php b/includes/user/User.php index 11cfd4956d..f0b2c57923 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -909,6 +909,8 @@ class User implements IDBAccessObject, UserIdentity { * @return int|null The corresponding user's ID, or null if user is nonexistent */ public static function idFromName( $name, $flags = self::READ_NORMAL ) { + // Don't explode on self::$idCacheByName[$name] if $name is not a string but e.g. a User object + $name = (string)$name; $nt = Title::makeTitleSafe( NS_USER, $name ); if ( is_null( $nt ) ) { // Illegal name