Skip to content

Commit 5c2a95e

Browse files
authored
Merge pull request #57632 from nextcloud/backport/57517/stable30
[stable30] Use strict array search
2 parents d2a8c00 + 2f001d9 commit 5c2a95e

12 files changed

Lines changed: 15 additions & 14 deletions

File tree

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

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

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

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

275275
// associate the user language with the proper array
276-
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
276+
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'), true);
277277
$userLang = $languages['commonLanguages'][$userLangIndex];
278278
// search in the other languages
279279
if ($userLangIndex === false) {
280-
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
280+
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'), true);
281281
$userLang = $languages['otherLanguages'][$userLangIndex];
282282
}
283283
// if user language is not available but set somehow: show the actual code as name

‎apps/user_ldap/lib/Mapping/AbstractMapping.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function modify(IPreparedStatement $statement, $parameters) {
116116
* @return string|false
117117
*/
118118
public function getDNByName($name) {
119-
$dn = array_search($name, $this->cache);
119+
$dn = array_search($name, $this->cache, true);
120120
if ($dn === false && ($dn = $this->getXbyY('ldap_dn', 'owncloud_name', $name)) !== false) {
121121
$this->cache[$dn] = $name;
122122
}
@@ -373,7 +373,7 @@ public function unmap($name) {
373373
DELETE FROM `' . $this->getTableName() . '`
374374
WHERE `owncloud_name` = ?');
375375

376-
$dn = array_search($name, $this->cache);
376+
$dn = array_search($name, $this->cache, true);
377377
if ($dn !== false) {
378378
unset($this->cache[$dn]);
379379
}

‎apps/user_ldap/tests/User/DeletedUsersIndexTest.php‎

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

‎apps/user_status/lib/Listener/UserLiveStatusListener.php‎

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

8888
// If the emitted status is more important than the current status
8989
// treat it as outdated and update
90-
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES)) {
90+
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true)) {
9191
$needsUpdate = true;
9292
}
9393

‎build/integration/features/bootstrap/Trashbin.php‎

Lines changed: 1 addition & 1 deletion
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
}

‎build/integration/features/bootstrap/WebDav.php‎

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

409409
foreach ($table->getRows() as $row) {
410-
$key = array_search($row[0], $foundTypes);
410+
$key = array_search($row[0], $foundTypes, true);
411411
if ($key === false) {
412412
throw new \Exception('Expected type ' . $row[0] . ' not found');
413413
}

‎lib/base.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ private static function registerAppRestrictionsHooks(): void {
892892
if (empty($restrictions)) {
893893
continue;
894894
}
895-
$key = array_search($group->getGID(), $restrictions);
895+
$key = array_search($group->getGID(), $restrictions, true);
896896
unset($restrictions[$key]);
897897
$restrictions = array_values($restrictions);
898898
if (empty($restrictions)) {

‎lib/private/Accounts/AccountManager.php‎

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

‎lib/private/Files/Storage/Local.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function file_exists($path) {
252252
return false;
253253
}
254254
$content = scandir($parentPath, SCANDIR_SORT_NONE);
255-
return is_array($content) && array_search(basename($fullPath), $content) !== false;
255+
return is_array($content) && array_search(basename($fullPath), $content, true) !== false;
256256
} else {
257257
return file_exists($this->getSourcePath($path));
258258
}

0 commit comments

Comments
 (0)