1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 04:04:12 +02:00

Merge branch '3.3.x'

This commit is contained in:
Marc Alexander
2021-11-01 16:57:35 +01:00
9 changed files with 117 additions and 5 deletions

View File

@@ -31,9 +31,11 @@ class manager
protected $finder_factory;
protected $cache;
protected $extensions;
protected $recently_changed_ext_status;
protected $extension_table;
protected $phpbb_root_path;
protected $cache_name;
protected $router;
/**
* Creates a manager and loads information from database
@@ -41,12 +43,14 @@ class manager
* @param ContainerInterface $container A container
* @param \phpbb\db\driver\driver_interface $db A database connection
* @param \phpbb\config\config $config Config object
* @param finder_factory $finder_factory Finder factory
* @param \phpbb\routing\router $router Router
* @param string $extension_table The name of the table holding extensions
* @param string $phpbb_root_path Path to the phpbb includes directory.
* @param \phpbb\cache\service|null $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext
*/
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, finder_factory $finder_factory, $extension_table, $phpbb_root_path, \phpbb\cache\service $cache = null, $cache_name = '_ext')
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, finder_factory $finder_factory, \phpbb\routing\router $router, $extension_table, $phpbb_root_path, \phpbb\cache\service $cache = null, $cache_name = '_ext')
{
$this->cache = $cache;
$this->cache_name = $cache_name;
@@ -54,6 +58,7 @@ class manager
$this->finder_factory = $finder_factory;
$this->container = $container;
$this->db = $db;
$this->router = $router;
$this->extension_table = $extension_table;
$this->phpbb_root_path = $phpbb_root_path;
@@ -236,6 +241,12 @@ class manager
'ext_state' => serialize($state),
);
if ($active)
{
$this->recently_changed_ext_status[$name] = false;
$this->router->without_cache();
}
$this->update_state($name, $extension_data, $this->is_configured($name) ? 'update' : 'insert');
if ($active)
@@ -285,6 +296,12 @@ class manager
$state = $extension->disable_step($old_state);
$active = ($state !== false);
if (!$active)
{
$this->recently_changed_ext_status[$name] = true;
$this->router->without_cache();
}
$extension_data = array(
'ext_active' => $active,
'ext_state' => serialize($state),
@@ -497,6 +514,13 @@ class manager
*/
public function is_enabled($name)
{
// The extension has just been enabled and so is not loaded. When asking if it is enabled or
// not we should answer no to stay consistent with the status at the beginning of the request.
if (isset($this->recently_changed_ext_status[$name]))
{
return $this->recently_changed_ext_status[$name];
}
return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active'];
}
@@ -508,6 +532,13 @@ class manager
*/
public function is_disabled($name)
{
// The extension has just been disabled and so is still loaded. When asking if it is disabled or
// not we should answer yes to stay consistent with the status at the beginning of the request.
if (isset($this->recently_changed_ext_status[$name]))
{
return $this->recently_changed_ext_status[$name];
}
return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active'];
}