From 3c80b7f2b34f08c84b77a8d3917c11c2a393880c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 13 Jan 2026 11:48:04 +0100 Subject: [PATCH] fix: Use strict array comparisons in lib/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid surprises with corner cases. Signed-off-by: Côme Chilliet --- lib/base.php | 2 +- lib/private/Accounts/AccountManager.php | 2 +- lib/private/Files/Storage/Local.php | 2 +- lib/private/L10N/Factory.php | 2 +- lib/private/Tags.php | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/base.php b/lib/base.php index b656158b530..632d19968a6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -970,7 +970,7 @@ class OC { if (empty($restrictions)) { continue; } - $key = array_search($group->getGID(), $restrictions); + $key = array_search($group->getGID(), $restrictions, true); unset($restrictions[$key]); $restrictions = array_values($restrictions); if (empty($restrictions)) { diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 1189712ba8d..373a697a327 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -354,7 +354,7 @@ class AccountManager implements IAccountManager { protected function addMissingDefaultValues(array $userData, array $defaultUserData): array { foreach ($defaultUserData as $defaultDataItem) { // If property does not exist, initialize it - $userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name')); + $userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'), true); if ($userDataIndex === false) { $userData[] = $defaultDataItem; continue; diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 260f9218a88..c46d4c6c8eb 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -250,7 +250,7 @@ class Local extends \OC\Files\Storage\Common { return false; } $content = scandir($parentPath, SCANDIR_SORT_NONE); - return is_array($content) && array_search(basename($fullPath), $content) !== false; + return is_array($content) && array_search(basename($fullPath), $content, true) !== false; } else { return file_exists($this->getSourcePath($path)); } diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index fa8cc51f606..abe392335f5 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -654,7 +654,7 @@ class Factory implements IFactory { // put appropriate languages into appropriate arrays, to print them sorted // common languages -> divider -> other languages if (in_array($lang, self::COMMON_LANGUAGE_CODES)) { - $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln; + $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES, true)] = $ln; } else { $otherLanguages[] = $ln; } diff --git a/lib/private/Tags.php b/lib/private/Tags.php index fb59fb670a6..f117a3a7f7c 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -645,7 +645,8 @@ class Tags implements ITags { return array_search(strtolower($needle), array_map( function ($tag) use ($mem) { return strtolower(call_user_func([$tag, $mem])); - }, $haystack) + }, $haystack), + true ); }