aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2012-11-14 15:42:13 -0500
committerDavid King <imkingdavid@gmail.com>2012-11-16 17:05:40 -0500
commitd3aa8823b21990634f8b74676ac301739ddfc58b (patch)
tree35de6c4e09a19af4fc430457daa6606886043ccd /phpBB/includes/functions.php
parent5877bf1b1b3dc2899543d99859e3bde6e70d8647 (diff)
downloadforums-d3aa8823b21990634f8b74676ac301739ddfc58b.tar
forums-d3aa8823b21990634f8b74676ac301739ddfc58b.tar.gz
forums-d3aa8823b21990634f8b74676ac301739ddfc58b.tar.bz2
forums-d3aa8823b21990634f8b74676ac301739ddfc58b.tar.xz
forums-d3aa8823b21990634f8b74676ac301739ddfc58b.zip
[feature/controller] Use a dumped url matcher class to improve performance
PHPBB3-10864
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index fb05b74cd3..7cf5611dca 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,6 +7,9 @@
*
*/
+use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
+use Symfony\Component\Routing\RequestContext;
+
/**
* @ignore
*/
@@ -5444,3 +5447,52 @@ function phpbb_to_numeric($input)
{
return ($input > PHP_INT_MAX) ? (float) $input : (int) $input;
}
+
+/**
+* Create and/or return the cached phpbb_url_matcher class
+*
+* If the class already exists, it instantiates it
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return phpbb_url_matcher
+*/
+function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $root_path, $php_ext)
+{
+ $matcher = phpbb_load_url_matcher($finder, $context, $root_path, $php_ext);
+ if ($matcher === false)
+ {
+ $provider = new phpbb_controller_provider();
+ $dumper = new PhpMatcherDumper($provider->get_paths($finder)->find());
+ $cached_url_matcher_dump = $dumper->dump(array(
+ 'class' => 'phpbb_url_matcher',
+ ));
+
+ file_put_contents($root_path . 'cache/url_matcher' . $php_ext, $cached_url_matcher_dump);
+ return phpbb_load_url_matcher($finder, $context, $root_path, $php_ext);
+ }
+
+ return $matcher;
+}
+
+/**
+* Load the cached phpbb_url_matcher class
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return phpbb_url_matcher|bool False if the file doesn't exist
+*/
+function phpbb_load_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $root_path, $php_ext)
+{
+ if (file_exists($root_path . 'cache/url_matcher' . $php_ext))
+ {
+ include($root_path . 'cache/url_matcher' . $php_ext);
+ return new phpbb_url_matcher($context);
+ }
+
+ return false;
+}