diff options
author | javiexin <javiexin@gmail.com> | 2016-12-26 21:07:31 +0100 |
---|---|---|
committer | javiexin <javiexin@gmail.com> | 2016-12-26 21:07:31 +0100 |
commit | efc2b46303614b0824d3f58f51778e7ff925ccf5 (patch) | |
tree | c885378ba41fe6d4524587e8cbc64b0d388f45ea | |
parent | 3322117c3863c443ca1b79d25541bde4c662c0ed (diff) | |
download | forums-efc2b46303614b0824d3f58f51778e7ff925ccf5.tar forums-efc2b46303614b0824d3f58f51778e7ff925ccf5.tar.gz forums-efc2b46303614b0824d3f58f51778e7ff925ccf5.tar.bz2 forums-efc2b46303614b0824d3f58f51778e7ff925ccf5.tar.xz forums-efc2b46303614b0824d3f58f51778e7ff925ccf5.zip |
[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
PHPBB3-14938
-rw-r--r-- | phpBB/phpbb/extension/manager.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 76f0e3558e..770c574dd5 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -524,7 +524,29 @@ class manager */ public function is_available($name) { - return file_exists($this->get_extension_path($name, true)); + // Not available if the folder does not exist + if (!file_exists($this->get_extension_path($name, true))) + { + 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; } /** |