aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaviexin <javiexin@gmail.com>2017-02-12 14:10:58 +0100
committerjaviexin <javiexin@gmail.com>2017-02-12 14:10:58 +0100
commit5266821e1b5b271e69b00d717b9e9b1f77b65b9f (patch)
tree252fc12631103cf85e44fd94c1d7a7d75681f9f8
parent17f8c53ef3c1101d8f90752b70f78a4f5c1c9ae2 (diff)
downloadforums-5266821e1b5b271e69b00d717b9e9b1f77b65b9f.tar
forums-5266821e1b5b271e69b00d717b9e9b1f77b65b9f.tar.gz
forums-5266821e1b5b271e69b00d717b9e9b1f77b65b9f.tar.bz2
forums-5266821e1b5b271e69b00d717b9e9b1f77b65b9f.tar.xz
forums-5266821e1b5b271e69b00d717b9e9b1f77b65b9f.zip
[ticket/15087] Optimize creation of metadata objects by caching
Code for [ticket/14938] Inconsistency in ext_mgr all_available vs is_available for phpbb 3.2. PHPBB3-15087
-rw-r--r--phpBB/phpbb/extension/manager.php28
1 files changed, 11 insertions, 17 deletions
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index b2b60aaa9b..22522d0785 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -431,25 +431,11 @@ class manager
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->get_extension_path($ext_name, true);
}
-
- $available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
}
}
ksort($available);
@@ -527,7 +513,15 @@ class manager
*/
public function is_available($name)
{
- return file_exists($this->get_extension_path($name, true));
+ $md_manager = $this->create_extension_metadata_manager($name);
+ try
+ {
+ return $md_manager->get_metadata('all') && $md_manager->validate_enable();
+ }
+ catch (\phpbb\extension\exception $e)
+ {
+ return false;
+ }
}
/**