[ticket/13829] Don't fail if the cache isn't writeable

PHPBB3-13829
This commit is contained in:
Nicofuma 2015-05-10 19:18:10 +02:00
parent 11167f6060
commit d48e95bb3a

View file

@ -14,6 +14,7 @@
namespace phpbb\routing; namespace phpbb\routing;
use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper; use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\Matcher\UrlMatcher;
@ -248,6 +249,8 @@ class router implements RouterInterface
* Creates a new dumped URL Matcher (dump it if necessary) * Creates a new dumped URL Matcher (dump it if necessary)
*/ */
protected function create_dumped_url_matcher() protected function create_dumped_url_matcher()
{
try
{ {
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_matcher.{$this->php_ext}", defined('DEBUG')); $cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_matcher.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh()) if (!$cache->isFresh())
@ -266,6 +269,11 @@ class router implements RouterInterface
$this->matcher = new \phpbb_url_matcher($this->context); $this->matcher = new \phpbb_url_matcher($this->context);
} }
catch (IOException $e)
{
$this->create_new_url_matcher();
}
}
/** /**
* Creates a new URL Matcher * Creates a new URL Matcher
@ -296,6 +304,8 @@ class router implements RouterInterface
* Creates a new dumped URL Generator (dump it if necessary) * Creates a new dumped URL Generator (dump it if necessary)
*/ */
protected function create_dumped_url_generator() protected function create_dumped_url_generator()
{
try
{ {
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_generator.{$this->php_ext}", defined('DEBUG')); $cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_generator.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh()) if (!$cache->isFresh())
@ -314,6 +324,11 @@ class router implements RouterInterface
$this->generator = new \phpbb_url_generator($this->context); $this->generator = new \phpbb_url_generator($this->context);
} }
catch (IOException $e)
{
$this->create_new_url_generator();
}
}
/** /**
* Creates a new URL Generator * Creates a new URL Generator