mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #57517 from nextcloud/backport/57509/stable31
[stable31] Use strict array search
This commit is contained in:
commit
e0f92e08c1
12 changed files with 15 additions and 14 deletions
|
|
@ -120,7 +120,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
|
|||
$isFav = false;
|
||||
$tags = $this->getTags($fileId);
|
||||
if ($tags) {
|
||||
$favPos = array_search(self::TAG_FAVORITE, $tags);
|
||||
$favPos = array_search(self::TAG_FAVORITE, $tags, true);
|
||||
if ($favPos !== false) {
|
||||
$isFav = true;
|
||||
unset($tags[$favPos]);
|
||||
|
|
|
|||
|
|
@ -238,11 +238,11 @@ class PersonalInfo implements ISettings {
|
|||
$languages = $this->l10nFactory->getLanguages();
|
||||
|
||||
// associate the user language with the proper array
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'), true);
|
||||
$userLang = $languages['commonLanguages'][$userLangIndex];
|
||||
// search in the other languages
|
||||
if ($userLangIndex === false) {
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'), true);
|
||||
$userLang = $languages['otherLanguages'][$userLangIndex];
|
||||
}
|
||||
// if user language is not available but set somehow: show the actual code as name
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ abstract class AbstractMapping {
|
|||
* @return string|false
|
||||
*/
|
||||
public function getDNByName($name) {
|
||||
$dn = array_search($name, $this->cache);
|
||||
$dn = array_search($name, $this->cache, true);
|
||||
if ($dn === false && ($dn = $this->getXbyY('ldap_dn', 'owncloud_name', $name)) !== false) {
|
||||
$this->cache[$dn] = $name;
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ abstract class AbstractMapping {
|
|||
DELETE FROM `' . $this->getTableName() . '`
|
||||
WHERE `owncloud_name` = ?');
|
||||
|
||||
$dn = array_search($name, $this->cache);
|
||||
$dn = array_search($name, $this->cache, true);
|
||||
if ($dn !== false) {
|
||||
unset($this->cache[$dn]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class DeletedUsersIndexTest extends \Test\TestCase {
|
|||
// ensure the different uids were used
|
||||
foreach ($deletedUsers as $deletedUser) {
|
||||
$this->assertTrue(in_array($deletedUser->getOCName(), $uids));
|
||||
$i = array_search($deletedUser->getOCName(), $uids);
|
||||
$i = array_search($deletedUser->getOCName(), $uids, true);
|
||||
$this->assertNotFalse($i);
|
||||
unset($uids[$i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class UserLiveStatusListener implements IEventListener {
|
|||
|
||||
// If the emitted status is more important than the current status
|
||||
// treat it as outdated and update
|
||||
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES)) {
|
||||
if (array_search($event->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true) < array_search($userStatus->getStatus(), StatusService::PRIORITY_ORDERED_STATUSES, true)) {
|
||||
$needsUpdate = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ trait Trashbin {
|
|||
$elementsSimplified = $this->simplifyArray($elementRows);
|
||||
foreach ($elementsSimplified as $expectedElement) {
|
||||
$expectedElement = ltrim($expectedElement, '/');
|
||||
if (array_search($expectedElement, $trashContent) === false) {
|
||||
if (array_search($expectedElement, $trashContent, true) === false) {
|
||||
Assert::fail("$expectedElement" . ' is not in trash listing');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ trait WebDav {
|
|||
}
|
||||
|
||||
foreach ($table->getRows() as $row) {
|
||||
$key = array_search($row[0], $foundTypes);
|
||||
$key = array_search($row[0], $foundTypes, true);
|
||||
if ($key === false) {
|
||||
throw new \Exception('Expected type ' . $row[0] . ' not found');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -923,7 +923,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)) {
|
||||
|
|
|
|||
|
|
@ -353,7 +353,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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,7 +633,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue