mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/15087] Optimize creation of metadata objects by caching
Caching is done in ext_manager, and metadata_manager is further simplified by reducing the number of parameters needed. Also, move template output function from metadata_manager to acp_extensions, where it belongs. PHPBB3-15087
This commit is contained in:
@@ -152,7 +152,12 @@ class manager
|
||||
*/
|
||||
public function create_extension_metadata_manager($name)
|
||||
{
|
||||
return new \phpbb\extension\metadata_manager($name, $this->config, $this, $this->phpbb_root_path);
|
||||
if (!isset($this->extensions[$name]['metadata']))
|
||||
{
|
||||
$metadata = new \phpbb\extension\metadata_manager($name, $this->get_extension_path($name, true));
|
||||
$this->extensions[$name]['metadata'] = $metadata;
|
||||
}
|
||||
return $this->extensions[$name]['metadata'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +173,7 @@ class manager
|
||||
public function enable_step($name)
|
||||
{
|
||||
// ignore extensions that are already enabled
|
||||
if (isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'])
|
||||
if ($this->is_enabled($name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -258,7 +263,7 @@ class manager
|
||||
public function disable_step($name)
|
||||
{
|
||||
// ignore extensions that are already disabled
|
||||
if (!isset($this->extensions[$name]) || !$this->extensions[$name]['ext_active'])
|
||||
if ($this->is_disabled($name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -336,8 +341,8 @@ class manager
|
||||
*/
|
||||
public function purge_step($name)
|
||||
{
|
||||
// ignore extensions that do not exist
|
||||
if (!isset($this->extensions[$name]))
|
||||
// ignore extensions that are not configured
|
||||
if (!$this->is_configured($name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -458,8 +463,12 @@ class manager
|
||||
$configured = array();
|
||||
foreach ($this->extensions as $name => $data)
|
||||
{
|
||||
$data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
|
||||
$configured[$name] = $data;
|
||||
if ($this->is_configured($name))
|
||||
{
|
||||
unset($data['metadata']);
|
||||
$data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
|
||||
$configured[$name] = $data;
|
||||
}
|
||||
}
|
||||
return $configured;
|
||||
}
|
||||
@@ -476,7 +485,7 @@ class manager
|
||||
$enabled = array();
|
||||
foreach ($this->extensions as $name => $data)
|
||||
{
|
||||
if ($data['ext_active'])
|
||||
if ($this->is_enabled($name))
|
||||
{
|
||||
$enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
|
||||
}
|
||||
@@ -497,7 +506,7 @@ class manager
|
||||
$disabled = array();
|
||||
foreach ($this->extensions as $name => $data)
|
||||
{
|
||||
if (!$data['ext_active'])
|
||||
if ($this->is_disabled($name))
|
||||
{
|
||||
$disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
|
||||
}
|
||||
@@ -532,7 +541,7 @@ class manager
|
||||
*/
|
||||
public function is_enabled($name)
|
||||
{
|
||||
return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'];
|
||||
return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,7 +552,7 @@ class manager
|
||||
*/
|
||||
public function is_disabled($name)
|
||||
{
|
||||
return isset($this->extensions[$name]) && !$this->extensions[$name]['ext_active'];
|
||||
return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -557,7 +566,7 @@ class manager
|
||||
*/
|
||||
public function is_configured($name)
|
||||
{
|
||||
return isset($this->extensions[$name]);
|
||||
return isset($this->extensions[$name]['ext_active']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user