[ticket/16956] Remove use of recently changed status for extensions

PHPBB3-16956
This commit is contained in:
Marc Alexander 2022-01-23 20:51:50 +01:00
parent 9bf6e7f32e
commit d08843853e
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 2 additions and 24 deletions

View file

@ -30,7 +30,6 @@ class manager
protected $cache; protected $cache;
protected $php_ext; protected $php_ext;
protected $extensions; protected $extensions;
protected $recently_changed_ext_status;
protected $extension_table; protected $extension_table;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $cache_name; protected $cache_name;
@ -243,7 +242,6 @@ class manager
if ($active) if ($active)
{ {
$this->recently_changed_ext_status[$name] = false;
$this->router->without_cache(); $this->router->without_cache();
} }
@ -298,7 +296,6 @@ class manager
if (!$active) if (!$active)
{ {
$this->recently_changed_ext_status[$name] = true;
$this->router->without_cache(); $this->router->without_cache();
} }
@ -514,13 +511,6 @@ class manager
*/ */
public function is_enabled($name) 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']; return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active'];
} }
@ -532,13 +522,6 @@ class manager
*/ */
public function is_disabled($name) 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']; return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active'];
} }

View file

@ -97,9 +97,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
$this->extension_manager->enable('vendor2/bar'); $this->extension_manager->enable('vendor2/bar');
// We should not display the extension as being enabled in the same request // We should see the extension as being disabled
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
// With a different request we should see the extension as being disabled
$this->assertEquals(array('vendor2/bar', 'vendor2/foo'), array_keys($this->create_extension_manager()->all_enabled())); $this->assertEquals(array('vendor2/bar', 'vendor2/foo'), array_keys($this->create_extension_manager()->all_enabled()));
$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));
@ -126,10 +124,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
$this->extension_manager->disable('vendor2/foo'); $this->extension_manager->disable('vendor2/foo');
// We should still display the extension as being enabled in the current request $this->assertEquals([], array_keys($this->extension_manager->all_enabled()));
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
// With a different request we should see the extension as being disabled
$this->assertEquals(array(), array_keys($this->create_extension_manager()->all_enabled()));
$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); $this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));