mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
[ticket/16891] Do not change an extension status in the middle of a request
When enabling an extension, it should be considered as not being enabled for the entire request as if the "enabled" flag is switch during the request, the extension will stay not loaded (same when disabling an extension). Example when it can be an issue today : if the router is called for the first time after enabling the extension and if the extension uses a custom route loader (like phpbb/pages) then the router will fail because the custom route will be found but the custom loader will not be loaded and available. PHPBB3-16891
This commit is contained in:
@@ -80,6 +80,11 @@ class router implements RouterInterface
|
||||
*/
|
||||
protected $cache_dir;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $use_cache;
|
||||
|
||||
/**
|
||||
* Construct method
|
||||
*
|
||||
@@ -97,6 +102,7 @@ class router implements RouterInterface
|
||||
$this->php_ext = $php_ext;
|
||||
$this->context = new RequestContext();
|
||||
$this->cache_dir = $cache_dir;
|
||||
$this->use_cache = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,6 +182,22 @@ class router implements RouterInterface
|
||||
return $this->get_matcher()->match($pathinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the use of a cached URL generator and matcher
|
||||
*/
|
||||
public function with_cache()
|
||||
{
|
||||
$this->use_cache = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the use of a cached URL generator and matcher
|
||||
*/
|
||||
public function without_cache()
|
||||
{
|
||||
$this->use_cache = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UrlMatcher instance associated with this Router.
|
||||
*
|
||||
@@ -198,6 +220,12 @@ class router implements RouterInterface
|
||||
*/
|
||||
protected function create_dumped_url_matcher()
|
||||
{
|
||||
if (!$this->use_cache)
|
||||
{
|
||||
$this->create_new_url_matcher();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$cache = new ConfigCache("{$this->cache_dir}url_matcher.{$this->php_ext}", defined('DEBUG'));
|
||||
@@ -253,6 +281,12 @@ class router implements RouterInterface
|
||||
*/
|
||||
protected function create_dumped_url_generator()
|
||||
{
|
||||
if (!$this->use_cache)
|
||||
{
|
||||
$this->create_new_url_generator();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", defined('DEBUG'));
|
||||
|
Reference in New Issue
Block a user