aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/di
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2016-01-25 13:50:23 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-01-26 22:13:26 +0100
commitcc38bf550b6d044938532d96a98dd92767e69b61 (patch)
tree8f3bbb07b5c41753b271da12214c28282e0411e6 /phpBB/phpbb/di
parent56062a2635551c29b1b983e000f0d1ee6a482fb9 (diff)
downloadforums-cc38bf550b6d044938532d96a98dd92767e69b61.tar
forums-cc38bf550b6d044938532d96a98dd92767e69b61.tar.gz
forums-cc38bf550b6d044938532d96a98dd92767e69b61.tar.bz2
forums-cc38bf550b6d044938532d96a98dd92767e69b61.tar.xz
forums-cc38bf550b6d044938532d96a98dd92767e69b61.zip
[ticket/14129] Caches extensions autoloaders
PHPBB3-14129
Diffstat (limited to 'phpBB/phpbb/di')
-rw-r--r--phpBB/phpbb/di/container_builder.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 433847b285..9583da14f5 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -135,6 +135,11 @@ class container_builder
$config_cache = new ConfigCache($container_filename, defined('DEBUG'));
if ($this->use_cache && $config_cache->isFresh())
{
+ if ($this->use_extensions)
+ {
+ require($this->get_autoload_filename());
+ }
+
require($config_cache->getPath());
$this->container = new \phpbb_cache_container();
}
@@ -405,6 +410,15 @@ class container_builder
$extensions = $ext_container->get('ext.manager')->all_enabled();
// Load each extension found
+ $autoloaders = '<?php
+/**
+ * Loads all extensions custom auto-loaders.
+ *
+ * This file has been auto-generated
+ * by phpBB while loading the extensions.
+ */
+
+';
foreach ($extensions as $ext_name => $path)
{
$extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\\extension';
@@ -420,9 +434,14 @@ class container_builder
$filename = $path . 'vendor/autoload.php';
if (file_exists($filename))
{
- require $filename;
+ $autoloaders .= "require('{$filename}');\n";
}
}
+
+ $configCache = new ConfigCache($this->get_autoload_filename(), false);
+ $configCache->write($autoloaders);
+
+ require($this->get_autoload_filename());
}
else
{
@@ -540,6 +559,16 @@ class container_builder
}
/**
+ * Get the filename under which the dumped extensions autoloader will be stored.
+ *
+ * @return string Path for dumped extensions autoloader
+ */
+ protected function get_autoload_filename()
+ {
+ return $this->get_cache_dir() . 'autoload_' . md5($this->phpbb_root_path) . '.' . $this->php_ext;
+ }
+
+ /**
* Return the name of the current environment.
*
* @return string