Page MenuHomePhabricator

User::findUsersByGroup() does not order its results, but its test assumes it does
Closed, ResolvedPublic

Description

The User::findUsersByGroup() method, added in rMW43112b60dafe: Add User::findUsersByGroup(), seems to intend that its result array is ordered by user ID. At least its unit test assumes it does.

But since it uses UserArray::newFromIDs() to build that result array, which doesn't sort the results, that's not guaranteed.

Options include:

  • Have UserArray::newFromIDs() sort by ID.
  • Have User::findUsersByGroup() sort the UserArray, or make its own sorted query and use UserArray::newFromResult()
  • Fix the test to not assume the result is ordered.

BTW, I also note that if no users are found User::findUsersByGroup() will return an ArrayIterator rather than the UserArrayFromResult it claims it will return.