From 8e3b6314eaab9b4265e9e1c69ede1ec6a106c885 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Sat, 29 Aug 2020 20:14:21 +0100 Subject: [PATCH] [TheFreeNetwork] Fix invalid index on lookup --- modules/TheFreeNetwork/TheFreeNetworkModule.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/TheFreeNetwork/TheFreeNetworkModule.php b/modules/TheFreeNetwork/TheFreeNetworkModule.php index c15195de75..02367f377c 100644 --- a/modules/TheFreeNetwork/TheFreeNetworkModule.php +++ b/modules/TheFreeNetwork/TheFreeNetworkModule.php @@ -77,24 +77,21 @@ class TheFreeNetworkModule extends Module * @param string $uri * @param string $class profile class that triggered this event * @param int|null &$profile_id Profile:id associated with the remote entity found - * @return bool hook flag + * @return bool hook flag false * @throws AlreadyHandledException Do not allow to create a profile if a preferred protocol already has one */ public function onStartTFNLookup(string $uri, string $class, int &$profile_id = null): bool { - [$profile_id, $cls] = $this->lookup($uri, $class); + [$profile_id, $cls] = $this->lookup($uri, $class) ?? [null, null]; if (is_null($profile_id)) { $perf = common_config('performance', 'high'); - if (!$perf && $this->lrdd) { - // Force lookup with online resources - [$profile_id, $cls] = $this->lookup($uri, $class, true); - } + // Force lookup with online resources + (!$perf && $this->lrdd) && ([$profile_id, $cls] = $this->lookup($uri, $class, true)); } - // Lower means higher priority - if ($this->priority[$cls] < $this->priority[$class]) { + if (is_null($profile_id) && $this->priority[$cls] < $this->priority[$class]) { // Lower means higher priority throw new AlreadyHandledException("TheFreeNetworkModule->AlreadyHandled: $cls is preferred over $class"); }