Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/13372] Fix Url Generator/Matcher generation #3179

Merged
merged 2 commits into from Jan 24, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 17 additions & 28 deletions phpBB/phpbb/routing/router.php
Expand Up @@ -13,6 +13,7 @@

namespace phpbb\routing;

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
use Symfony\Component\Routing\Matcher\UrlMatcher;
Expand Down Expand Up @@ -232,14 +233,7 @@ public function get_matcher()
return $this->matcher;
}

if (defined('DEBUG'))
{
$this->create_new_url_matcher();
}
else
{
$this->create_dumped_url_matcher();
}
$this->create_dumped_url_matcher();

return $this->matcher;
}
Expand All @@ -248,21 +242,22 @@ public function get_matcher()
*/
protected function create_dumped_url_matcher()
{
if (!file_exists($this->phpbb_root_path . 'cache/url_matcher.' . $this->php_ext))
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_matcher.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh())
{
$dumper = new PhpMatcherDumper($this->get_routes());

$options = array(
'class' => 'phpbb_url_matcher',
'class' => 'phpbb_url_matcher',
'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
);

$dump = $dumper->dump($options);
file_put_contents($this->phpbb_root_path . 'cache/url_matcher.' . $this->php_ext, $dump);
$cache->write($dumper->dump($options), $this->get_routes()->getResources());
}

require_once($this->phpbb_root_path . 'cache/url_matcher.' . $this->php_ext);
require_once $cache;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep ()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


$this->matcher = new phpbb_url_matcher($this->context);
$this->matcher = new \phpbb_url_matcher($this->context);
}

/**
Expand All @@ -285,14 +280,7 @@ public function get_generator()
return $this->generator;
}

if (defined('DEBUG'))
{
$this->create_new_url_generator();
}
else
{
$this->create_dumped_url_generator();
}
$this->create_dumped_url_generator();

return $this->generator;
}
Expand All @@ -302,21 +290,22 @@ public function get_generator()
*/
protected function create_dumped_url_generator()
{
if (!file_exists($this->phpbb_root_path . 'cache/url_generator.' . $this->php_ext))
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_generator.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh())
{
$dumper = new PhpGeneratorDumper($this->get_routes());

$options = array(
'class' => 'phpbb_url_generator',
'class' => 'phpbb_url_generator',
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
);

$dump = $dumper->dump($options);
file_put_contents($this->phpbb_root_path . 'cache/url_generator.' . $this->php_ext, $dump);
$cache->write($dumper->dump($options), $this->get_routes()->getResources());
}

require_once($this->phpbb_root_path . 'cache/url_generator.' . $this->php_ext);
require_once $cache;

$this->generator = new phpbb_url_generator($this->context);
$this->generator = new \phpbb_url_generator($this->context);
}

/**
Expand Down