mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-19 07:00:14 +01:00
[ticket/14938] Inconsistency in ext_mgr all_available vs is_available
Made is_available much more strict, in line with the checks in all_available Refactor all_available to use is_available, saving duplicate code. Further simplify is_available by using metadata_manager. PHPBB3-14938
This commit is contained in:
parent
9658ecae8b
commit
abd6bd8154
@ -510,29 +510,15 @@ class manager
|
||||
*/
|
||||
public function is_available($name)
|
||||
{
|
||||
// Not available if the folder does not exist
|
||||
if (!file_exists($this->get_extension_path($name, true)))
|
||||
$md_manager = $this->create_extension_metadata_manager($name, $this->container->get('template'));
|
||||
try
|
||||
{
|
||||
return $md_manager->get_metadata('all') && $md_manager->validate_enable();
|
||||
}
|
||||
catch (\phpbb\extension\exception $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$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)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$ext_info = json_decode($ext_info, true);
|
||||
|
||||
// Not available if malformed name or if the directory structure
|
||||
// does not match the name value specified in composer.json.
|
||||
if (substr_count($name, '/') !== 1 || !isset($ext_info['name']) || $name != $ext_info['name'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user