Skip to content

Commit 0fa396d

Browse files
authored
Merge pull request #57509 from nextcloud/fix/use-strict-array-search
Use strict array search
2 parents 5acb93a + f31f4eb commit 0fa396d

File tree

13 files changed

+16
-15
lines changed

13 files changed

+16
-15
lines changed

apps/dav/lib/Connector/Sabre/TagsPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function getTagsAndFav($fileId) {
123123
$isFav = false;
124124
$tags = $this->getTags($fileId);
125125
if ($tags) {
126-
$favPos = array_search(self::TAG_FAVORITE, $tags);
126+
$favPos = array_search(self::TAG_FAVORITE, $tags, true);
127127
if ($favPos !== false) {
128128
$isFav = true;
129129
unset($tags[$favPos]);

apps/settings/lib/Settings/Personal/PersonalInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ private function getLanguageMap(IUser $user): array {
242242
$languages = $this->l10nFactory->getLanguages();
243243

244244
// associate the user language with the proper array
245-
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
245+
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'), true);
246246
$userLang = $languages['commonLanguages'][$userLangIndex];
247247
// search in the other languages
248248
if ($userLangIndex === false) {
249-
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
249+
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'), true);
250250
$userLang = $languages['otherLanguages'][$userLangIndex];
251251
}
252252
// if user language is not available but set somehow: show the actual code as name

apps/user_ldap/lib/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private function getServersConfig(string $value): array {
141141
*/
142142
public function deleteServerConfiguration($prefix) {
143143
$prefixes = $this->getServerConfigurationPrefixes();
144-
$index = array_search($prefix, $prefixes);
144+
$index = array_search($prefix, $prefixes, true);
145145
if ($index === false) {
146146
return false;
147147
}

apps/user_ldap/lib/Mapping/AbstractMapping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public function unmap($name) {
447447
DELETE FROM `' . $this->getTableName() . '`
448448
WHERE `owncloud_name` = ?');
449449

450-
$dn = array_search($name, $this->cache);
450+
$dn = array_search($name, $this->cache, true);
451451
if ($dn !== false) {
452452
unset($this->cache[$dn]);
453453
}

apps/user_ldap/tests/User/DeletedUsersIndexTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testMarkAndFetchUser(): void {
7171
// ensure the different uids were used
7272
foreach ($deletedUsers as $deletedUser) {
7373
$this->assertTrue(in_array($deletedUser->getOCName(), $uids));
74-
$i = array_search($deletedUser->getOCName(), $uids);
74+
$i = array_search($deletedUser->getOCName(), $uids, true);
7575
$this->assertNotFalse($i);
7676
unset($uids[$i]);
7777
}

apps/user_status/lib/Listener/UserLiveStatusListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function handle(Event $event): void {
8282

8383
// If the emitted status is more important than the current status
8484
// treat it as outdated and update
85-
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES)) {
85+
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true)) {
8686
$needsUpdate = true;
8787
}
8888

build/integration/features/bootstrap/Trashbin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function checkTrashContents($user, $folder, $expectedElements) {
9797
$elementsSimplified = $this->simplifyArray($elementRows);
9898
foreach ($elementsSimplified as $expectedElement) {
9999
$expectedElement = ltrim($expectedElement, '/');
100-
if (array_search($expectedElement, $trashContent) === false) {
100+
if (array_search($expectedElement, $trashContent, true) === false) {
101101
Assert::fail("$expectedElement" . ' is not in trash listing');
102102
}
103103
}
@@ -121,7 +121,7 @@ public function checkTrashContains($user, $type, $file) {
121121
return $item['{http://nextcloud.org/ns}trashbin-filename'];
122122
}, $elementList));
123123

124-
if (array_search($name, array_values($trashContent)) === false) {
124+
if (array_search($name, array_values($trashContent), true) === false) {
125125
Assert::fail("$name" . ' is not in trash listing');
126126
}
127127
}

build/integration/features/bootstrap/WebDav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public function theResponseShouldContainAShareTypesPropertyWith($table) {
438438
}
439439

440440
foreach ($table->getRows() as $row) {
441-
$key = array_search($row[0], $foundTypes);
441+
$key = array_search($row[0], $foundTypes, true);
442442
if ($key === false) {
443443
throw new \Exception('Expected type ' . $row[0] . ' not found');
444444
}

lib/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ private static function registerAppRestrictionsHooks(): void {
970970
if (empty($restrictions)) {
971971
continue;
972972
}
973-
$key = array_search($group->getGID(), $restrictions);
973+
$key = array_search($group->getGID(), $restrictions, true);
974974
unset($restrictions[$key]);
975975
$restrictions = array_values($restrictions);
976976
if (empty($restrictions)) {

lib/private/Accounts/AccountManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ protected function sendEmailVerificationEmail(IUser $user, string $email): bool
354354
protected function addMissingDefaultValues(array $userData, array $defaultUserData): array {
355355
foreach ($defaultUserData as $defaultDataItem) {
356356
// If property does not exist, initialize it
357-
$userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'));
357+
$userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'), true);
358358
if ($userDataIndex === false) {
359359
$userData[] = $defaultDataItem;
360360
continue;

0 commit comments

Comments
 (0)