On Sun, Sep 5, 2021 at 1:18 PM Roy Smith <r...@panix.com> wrote: > > Sigh. It's even more complicated than that. It looks like the "name" entry > doesn't always match the name you passed in the API call, but is subject to > case mapping, trailing whitespace stripping, and maybe a few other things?
MediaWiki normalizes usernames using non-trivial rules [0]. The level of abstraction in this code will have you chase through a number of classes to figure out all of the rules. The "simple" version of canonicalizing a username is something like: * Replace all whitespace characters with underscores (`_`) * Reduce any runs of multiple underscores to a single underscore * Trim any leading or trailing underscores from the string * Capitalize the string The real rules are a bit more complicated than this [1] and include rejecting names containing certain special characters or runs of characters. > I'm assuming the entries in the returned "users" list are guaranteed to be in > the same order as the input parameters? I can't find anyplace that says > this, but it seems logical. Can somebody confirm that it's true? I see you've already figured this out from your follow up message, but for the sake of future readers, no. Each username provided to the query is normalized before querying the database and any invalid usernames are output first [2]. [0]: https://github.com/wikimedia/mediawiki/blob/02f7392231ef40a0f928fbd5ec791effc24361ff/includes/user/UserNameUtils.php#L244-L317 [1]: https://github.com/wikimedia/mediawiki/blob/02f7392231ef40a0f928fbd5ec791effc24361ff/includes/title/MediaWikiTitleCodec.php#L333-L579 [2]: https://github.com/wikimedia/mediawiki/blob/02f7392231ef40a0f928fbd5ec791effc24361ff/includes/api/ApiQueryUsers.php#L156-L173 Bryan -- Bryan Davis Technical Engagement Wikimedia Foundation Principal Software Engineer Boise, ID USA [[m:User:BDavis_(WMF)]] irc: bd808 _______________________________________________ Cloud mailing list -- cloud@lists.wikimedia.org List information: https://lists.wikimedia.org/postorius/lists/cloud.lists.wikimedia.org/