From 614dceed00bea7268bc3a2ddcd776e693ddb4b4d Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 31 Oct 2018 15:38:07 -0700 Subject: [PATCH] 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 --- includes/user/User.php | 2 ++ 1 file changed, 2 insertions(+) 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 -- 2.20.1