diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-21 11:39:08 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-21 11:39:08 +0100 |
commit | 510010e774c4019b7fc616c90085649abb7afac3 (patch) | |
tree | 79249d814204f06dc063fca211b3ae49c32fe65f | |
parent | 2992a1aa8842d53fa5afada76f5c4f66dc420b08 (diff) | |
parent | 843135e4ffc5a86435b72f177e3fee10d380a69c (diff) | |
download | nextcloud-server-510010e774c4019b7fc616c90085649abb7afac3.tar.gz nextcloud-server-510010e774c4019b7fc616c90085649abb7afac3.zip |
Merge pull request #18472 from owncloud/ext-array-filter
Replace array_filter() with foreach for PHP <5.6
-rw-r--r-- | apps/files_external/service/userglobalstoragesservice.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/files_external/service/userglobalstoragesservice.php b/apps/files_external/service/userglobalstoragesservice.php index 78520419556..c59652d057f 100644 --- a/apps/files_external/service/userglobalstoragesservice.php +++ b/apps/files_external/service/userglobalstoragesservice.php @@ -76,20 +76,25 @@ class UserGlobalStoragesService extends GlobalStoragesService { $data = parent::readLegacyConfig(); $userId = $this->getUser()->getUID(); + // don't use array_filter() with ARRAY_FILTER_USE_KEY, it's PHP 5.6+ if (isset($data[\OC_Mount_Config::MOUNT_TYPE_USER])) { - $data[\OC_Mount_Config::MOUNT_TYPE_USER] = array_filter( - $data[\OC_Mount_Config::MOUNT_TYPE_USER], function($key) use ($userId) { - return (strtolower($key) === strtolower($userId) || $key === 'all'); - }, ARRAY_FILTER_USE_KEY - ); + $newData = []; + foreach ($data[\OC_Mount_Config::MOUNT_TYPE_USER] as $key => $value) { + if (strtolower($key) === strtolower($userId) || $key === 'all') { + $newData[$key] = $value; + } + } + $data[\OC_Mount_Config::MOUNT_TYPE_USER] = $newData; } if (isset($data[\OC_Mount_Config::MOUNT_TYPE_GROUP])) { - $data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = array_filter( - $data[\OC_Mount_Config::MOUNT_TYPE_GROUP], function($key) use ($userId) { - return ($this->groupManager->isInGroup($userId, $key)); - }, ARRAY_FILTER_USE_KEY - ); + $newData = []; + foreach ($data[\OC_Mount_Config::MOUNT_TYPE_GROUP] as $key => $value) { + if ($this->groupManager->isInGroup($userId, $key)) { + $newData[$key] = $value; + } + } + $data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = $newData; } return $data; |