Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,12 @@ private function normaliseUserIds(array $userIds): array {
// replaces called in_array() against a growing array, making the walk
// quadratic in the number of distinct ids.
//
// Not a keyed set: PHP coerces a numeric-string array key to int, and
// Nextcloud user ids may be numeric strings, so "0123" would come back
// as 123.
// Not a keyed set. PHP coerces an array key that is a CANONICAL decimal
// integer string, so a user id of "123" or "-7" comes back from
// array_keys() as an int, while "0123", "007" and "1e3" stay strings.
// Nextcloud user ids may be numeric, so the ones that survive and the
// ones that change type would depend on the id - which is worse than
// if it broke uniformly.
return array_values(
array_unique(
array_filter(
Expand Down
8 changes: 5 additions & 3 deletions tests/Unit/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,12 @@ public function testRecipientCertificatesReportsBothShareableAndNot(): void {
}//end testRecipientCertificatesReportsBothShareableAndNot()

/**
* Input order is preserved and duplicates collapse.
* Duplicates collapse, and first-seen order is kept.
*
* The caller zips the response against the list it sent, so order is part
* of the contract, not an accident of the query.
* Order is a convenience, NOT a positional contract - the result can be
* shorter than the request, so callers correlate by `userId`. Asserted
* here because the order is still the one a reader would expect, not
* because anything may depend on the positions lining up.
*
* @return void
*/
Expand Down
Loading