Background
TemporaryAccountHandler returns a list of IPs used by a temporary account.
The returned list should be an array, e.g.:
{ "ips": [ "192:168:1:1:0:0:0:0" ] }
However, sometimes an object is returned with numerical indices that are non-sequential, e.g.:
{ "ips": { "0": "192:168:1:1:0:0:0:0", "2": "192:168:1:0:0:0:0:0" } }
This should instead be:
{
"ips": [
"0": "192:168:1:1:0:0:0:0",
"1": "192:168:1:0:0:0:0:0"
]
}This might only happen if there are multiple rows for the same actor-IP-timestamp. For more information see T324603#8577985 and the following comments.
Acceptance criteria
- The returned list of IPs is always an array
Notes
The problem might arise here when calling array_unique here: https://gerrit.wikimedia.org/g/mediawiki/extensions/CheckUser/+/d5a63f4df9c6f77310c3ebbf6e90baa56136d9e5/src/Api/Rest/Handler/TemporaryAccountHandler.php#47 Could we use something like array_values(array_unique($ips))?
Testing Notes
-To use this API, you'll need the checkuser-temporary-account right that's introduced in this patch.You must also have Enable revealing IP addresses for temporary accounts enabled on your Special:Preferences
-The URL is rest.php/checkuser/v0/temporaryaccount/{name}, where {name} is the user name you want to look up (see RestRoutes in extension.json)
-You can add the optional params in TemporaryAccountHandler::getParamSettings via the querystring (e.g. ?revision=123, etc)
-In case you have been switching $wgAutoCreateTempUser['enabled'] on and off locally, it needs to be true to avoid a nonexistent account error
-Visiting this URL : http://localhost:8080/w/rest.php/checkuser/v0/temporaryaccount/{nameoftemporaryaccount} should give JSON object with a single key "ips" which maps to an array of unique IP addresses used by a temporary account