Replace array_filter() with foreach for PHP <5.6
ARRAY_FILTER_USE_KEY is PHP 5.6+
This commit is contained in:
parent
f5bbe727df
commit
843135e4ff
1 changed files with 15 additions and 10 deletions
|
@ -76,20 +76,25 @@ class UserGlobalStoragesService extends GlobalStoragesService {
|
||||||
$data = parent::readLegacyConfig();
|
$data = parent::readLegacyConfig();
|
||||||
$userId = $this->getUser()->getUID();
|
$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])) {
|
if (isset($data[\OC_Mount_Config::MOUNT_TYPE_USER])) {
|
||||||
$data[\OC_Mount_Config::MOUNT_TYPE_USER] = array_filter(
|
$newData = [];
|
||||||
$data[\OC_Mount_Config::MOUNT_TYPE_USER], function($key) use ($userId) {
|
foreach ($data[\OC_Mount_Config::MOUNT_TYPE_USER] as $key => $value) {
|
||||||
return (strtolower($key) === strtolower($userId) || $key === 'all');
|
if (strtolower($key) === strtolower($userId) || $key === 'all') {
|
||||||
}, ARRAY_FILTER_USE_KEY
|
$newData[$key] = $value;
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
$data[\OC_Mount_Config::MOUNT_TYPE_USER] = $newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data[\OC_Mount_Config::MOUNT_TYPE_GROUP])) {
|
if (isset($data[\OC_Mount_Config::MOUNT_TYPE_GROUP])) {
|
||||||
$data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = array_filter(
|
$newData = [];
|
||||||
$data[\OC_Mount_Config::MOUNT_TYPE_GROUP], function($key) use ($userId) {
|
foreach ($data[\OC_Mount_Config::MOUNT_TYPE_GROUP] as $key => $value) {
|
||||||
return ($this->groupManager->isInGroup($userId, $key));
|
if ($this->groupManager->isInGroup($userId, $key)) {
|
||||||
}, ARRAY_FILTER_USE_KEY
|
$newData[$key] = $value;
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
$data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = $newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
Loading…
Reference in a new issue