Skip to content

Commit

Permalink
[ticket/14938] Inconsistency in ext_mgr all_available vs is_available
Browse files Browse the repository at this point in the history
Made is_available much more strict, in line with the checks in all_available
Refactor all_available to use is_available, saving duplicate code.

PHPBB3-14938
  • Loading branch information
javiexin committed Dec 30, 2016
1 parent efc2b46 commit 3559cea
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions phpBB/phpbb/extension/manager.php
Expand Up @@ -433,27 +433,13 @@ public function all_available()
if ($file_info->isFile() && $file_info->getFilename() == 'composer.json')
{
$ext_name = $iterator->getInnerIterator()->getSubPath();
$composer_file = $iterator->getPath() . '/composer.json';

// Ignore the extension if there is no composer.json.
if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file)))
{
continue;
}

$ext_info = json_decode($ext_info, true);
$ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name);

// Ignore the extension if directory depth is not correct or if the directory structure
// does not match the name value specified in composer.json.
if (substr_count($ext_name, '/') !== 1 || !isset($ext_info['name']) || $ext_name != $ext_info['name'])
if ($this->is_available($ext_name))
{
continue;
}

$available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
}
}
}
ksort($available);
return $available;
}
Expand Down Expand Up @@ -530,7 +516,7 @@ public function is_available($name)
return false;
}

$composer_file = $this->get_extension_path($name, true) . '/composer.json';
$composer_file = $this->get_extension_path($name, true) . 'composer.json';

// Not available if there is no composer.json.
if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file)))
Expand Down

0 comments on commit 3559cea

Please sign in to comment.