diff options
author | Julien Veyssier <julien-nc@posteo.net> | 2023-01-26 13:00:16 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2023-01-27 11:10:56 +0100 |
commit | b22d4e630650c2316d96f16b331a3e02c32da3d9 (patch) | |
tree | 49dbb33785a0a8cfa0fcb221ea63ac074d557efe /lib | |
parent | 8766e4f2429954408e8a7424430e677a69228f8a (diff) | |
download | nextcloud-server-b22d4e630650c2316d96f16b331a3e02c32da3d9.tar.gz nextcloud-server-b22d4e630650c2316d96f16b331a3e02c32da3d9.zip |
use array_filter instead of array_map + array_search
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/Reference/ReferenceManager.php | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php index 5db30a50ea6..52f09d3a879 100644 --- a/lib/private/Collaboration/Reference/ReferenceManager.php +++ b/lib/private/Collaboration/Reference/ReferenceManager.php @@ -244,15 +244,15 @@ class ReferenceManager implements IReferenceManager { */ public function touchProvider(string $userId, string $providerId, ?int $timestamp = null): bool { $providers = $this->getDiscoverableProviders(); - $providerIds = array_map(static function (IDiscoverableReferenceProvider $provider) { - return $provider->getId(); - }, $providers); - if (array_search($providerId, $providerIds, true) !== false) { - $configKey = 'provider-last-use_' . $providerId; + $matchingProviders = array_filter($providers, static function (IDiscoverableReferenceProvider $provider) use ($providerId) { + return $provider->getId() === $providerId; + }); + if (!empty($matchingProviders)) { if ($timestamp === null) { $timestamp = time(); } + $configKey = 'provider-last-use_' . $providerId; $this->config->setUserValue($userId, 'references', $configKey, (string) $timestamp); return true; } |