Skip to content

Conversation

@come-nc
Copy link
Contributor

@come-nc come-nc commented Jan 13, 2026

  • Resolves: #

Summary

Without strict:true, array_search has an unexpected behavior with string looking like numbers.

Example:

<?php

$cache = [
	'user1' => '000E01',
	'user2' => '000F02',
];

// All of these calls return 'user1'
var_dump(
	array_search('000E02',    $cache),
	array_search('00E02',     $cache),
	array_search('0E02',      $cache),
	array_search('0E0',       $cache),
	array_search('0E01',      $cache),
);

I splitted in several commits to ease backporting a bit.

The issue was spotted with user_ldap user cache, but all instances of array_search could be impacted with such a corner case so I added strict:true to all array_search calls, apart from object arrays.

Checklist

Otherwise there are issues with string values looking like numbers.

Signed-off-by: Côme Chilliet <[email protected]>
To avoid surprises with corner cases.

Signed-off-by: Côme Chilliet <[email protected]>
@come-nc come-nc added this to the Nextcloud 33 milestone Jan 13, 2026
@come-nc come-nc self-assigned this Jan 13, 2026
@come-nc come-nc requested a review from a team as a code owner January 13, 2026 10:56
@come-nc come-nc added the 3. to review Waiting for reviews label Jan 13, 2026
@come-nc come-nc requested review from Altahrim, nfebe, salmart-dev and sorbaugh and removed request for a team January 13, 2026 10:56
@come-nc
Copy link
Contributor Author

come-nc commented Jan 13, 2026

/backport to stable32

@come-nc
Copy link
Contributor Author

come-nc commented Jan 13, 2026

/backport to stable31

@susnux susnux merged commit 0fa396d into master Jan 13, 2026
209 of 215 checks passed
@susnux susnux deleted the fix/use-strict-array-search branch January 13, 2026 14:22
@nextcloud-bot nextcloud-bot mentioned this pull request Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants