(bug 33602) list=allusers throws exceptions with invalid names
authorSzymon Świerkosz <beau@adres.pl>
Sun, 15 Apr 2012 08:26:33 +0000 (10:26 +0200)
committerSzymon Świerkosz <beau@adres.pl>
Sun, 15 Apr 2012 08:37:03 +0000 (10:37 +0200)
commit6cf8cd357ec0370fdfafc8e2056a555b930a5d70
treed5b0576af6762881403f6680ab7a90acd25eaaf8
parentae7408460d9a32ec7629c21b967424d72467817b
(bug 33602) list=allusers throws exceptions with invalid names

Some MediaWiki installations have invalid user names in user table
(most notable example: en.wikipedia). This commit DOES NOT resolve
the issue completely, it only makes the API behave more gracefully.

I have replaced User::newFromName call with User::newFromId, so the
User object should be always constructed. In case it was not, an
empty array will be provided instead of null when returning user
rights. I have removed keyToTitle calls for ContinueEnumParameter
as user names in the database are stored without underscores
(en.wikipedia has of course one user with _ in the database...).
This should fix invalidtitle error thrown.

There is one issue I don't know how to solve. When API outputs in
query-continue aufrom value with invalid user name, subsequent
call with aufrom set will return an error, because input parameters
'from' and 'to' are passed to keyToTitle method too. Should I
replace it with simple str_replace('_', ' ')?

Change-Id: I7d115e734cb8c93dcf6dc3b98bdbc81975951273
includes/api/ApiQueryAllUsers.php