[TheFreeNetwork] Fix invalid index on lookup

Esse commit está contido em:
Diogo Cordeiro
2020-08-29 20:14:21 +01:00
commit 8e3b6314ea
+5 -8
Ver Arquivo
@@ -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");
}