mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/12631] Add finder.not_use_cache
PHPBB3-12631
This commit is contained in:
committed by
Marc Alexander
parent
38024d14bf
commit
9308764fae
@@ -64,6 +64,10 @@ class container_configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->booleanNode('force_sid')->defaultValue(false)->end()
|
||||
->booleanNode('log_errors')->defaultValue(false)->end()
|
||||
->arrayNode('finder')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('not_use_cache')->defaultValue(false)->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@@ -117,6 +117,11 @@ class core extends Extension
|
||||
foreach ($config['session'] as $name => $value)
|
||||
{
|
||||
$container->setParameter('session.' . $name, $value);
|
||||
|
||||
// Set the finder options
|
||||
foreach ($config['finder'] as $name => $value)
|
||||
{
|
||||
$container->setParameter('finder.' . $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class base implements \phpbb\extension\extension_interface
|
||||
/** @var ContainerInterface */
|
||||
protected $container;
|
||||
|
||||
/** @var \phpbb\finder */
|
||||
/** @var \phpbb\finder\finder */
|
||||
protected $extension_finder;
|
||||
|
||||
/** @var \phpbb\db\migrator */
|
||||
@@ -42,12 +42,12 @@ class base implements \phpbb\extension\extension_interface
|
||||
* Constructor
|
||||
*
|
||||
* @param ContainerInterface $container Container object
|
||||
* @param \phpbb\finder $extension_finder
|
||||
* @param \phpbb\finder\finder $extension_finder
|
||||
* @param \phpbb\db\migrator $migrator
|
||||
* @param string $extension_name Name of this extension (from ext.manager)
|
||||
* @param string $extension_path Relative path to this extension
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, \phpbb\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path)
|
||||
public function __construct(ContainerInterface $container, \phpbb\finder\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->extension_finder = $extension_finder;
|
||||
|
@@ -15,6 +15,7 @@ namespace phpbb\extension;
|
||||
|
||||
use phpbb\exception\runtime_exception;
|
||||
use phpbb\file_downloader;
|
||||
use phpbb\finder\factory as finder_factory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,8 @@ class manager
|
||||
|
||||
protected $db;
|
||||
protected $config;
|
||||
protected $finder_factory;
|
||||
protected $cache;
|
||||
protected $php_ext;
|
||||
protected $extensions;
|
||||
protected $extension_table;
|
||||
protected $phpbb_root_path;
|
||||
@@ -42,20 +43,19 @@ class manager
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param string $extension_table The name of the table holding extensions
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
* @param string $php_ext php file extension, defaults to php
|
||||
* @param \phpbb\cache\service|null $cache A cache instance or null
|
||||
* @param string $cache_name The name of the cache variable, defaults to _ext
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext')
|
||||
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, finder_factory $finder_factory, $extension_table, $phpbb_root_path, \phpbb\cache\service $cache = null, $cache_name = '_ext')
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->cache_name = $cache_name;
|
||||
$this->config = $config;
|
||||
$this->finder_factory = $finder_factory;
|
||||
$this->container = $container;
|
||||
$this->db = $db;
|
||||
$this->extension_table = $extension_table;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
$this->extensions = ($this->cache) ? $this->cache->get($this->cache_name) : false;
|
||||
|
||||
@@ -568,14 +568,15 @@ class manager
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a \phpbb\finder.
|
||||
* Instantiates a \phpbb\finder\finder.
|
||||
*
|
||||
* @param bool $use_all_available Should we load all extensions, or just enabled ones
|
||||
* @return \phpbb\finder An extension finder instance
|
||||
* @return \phpbb\finder\finder An extension finder instance
|
||||
*/
|
||||
public function get_finder($use_all_available = false)
|
||||
{
|
||||
$finder = new \phpbb\finder($this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
|
||||
$finder = $this->finder_factory->get($this->cache_name . '_finder');
|
||||
|
||||
if ($use_all_available)
|
||||
{
|
||||
$finder->set_extensions(array_keys($this->all_available()));
|
||||
@@ -584,6 +585,7 @@ class manager
|
||||
{
|
||||
$finder->set_extensions(array_keys($this->all_enabled()));
|
||||
}
|
||||
|
||||
return $finder;
|
||||
}
|
||||
}
|
||||
|
53
phpBB/phpbb/finder/factory.php
Normal file
53
phpBB/phpbb/finder/factory.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\finder;
|
||||
|
||||
/**
|
||||
* The finder provides a simple way to locate files in the core and a set of extensions
|
||||
*/
|
||||
class factory
|
||||
{
|
||||
protected $cache;
|
||||
protected $not_use_cache;
|
||||
protected $phpbb_root_path;
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Creates a new finder instance with its dependencies
|
||||
*
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory
|
||||
* @param \phpbb\cache\service $cache A cache instance or null
|
||||
* @param string $php_ext php file extension
|
||||
* @param string $cache_name The name of the cache variable, defaults to
|
||||
* _ext_finder
|
||||
*/
|
||||
public function __construct(/*\phpbb\cache\service */ $cache, $not_use_cache, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->not_use_cache = $not_use_cache;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cache variable name used to store $this->cached_queries in $this->cache.
|
||||
*
|
||||
* Allows the use of multiple differently configured finders with the same cache.
|
||||
* @var string
|
||||
*/
|
||||
public function get($cache_name = '_ext_finder')
|
||||
{
|
||||
return new finder($this->cache, $this->not_use_cache, $this->phpbb_root_path, $this->php_ext, $cache_name);
|
||||
}
|
||||
}
|
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb;
|
||||
namespace phpbb\finder;
|
||||
|
||||
use phpbb\filesystem\helper as filesystem_helper;
|
||||
|
||||
@@ -23,6 +23,7 @@ class finder
|
||||
protected $extensions;
|
||||
protected $phpbb_root_path;
|
||||
protected $cache;
|
||||
protected $not_use_cache;
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
@@ -55,10 +56,11 @@ class finder
|
||||
* @param string $cache_name The name of the cache variable, defaults to
|
||||
* _ext_finder
|
||||
*/
|
||||
public function __construct($phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
|
||||
public function __construct(/*\phpbb\cache\service */ $cache, $not_use_cache, $phpbb_root_path, $php_ext, $cache_name = '_ext_finder')
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->cache = $cache;
|
||||
$this->not_use_cache = $not_use_cache;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->cache_name = $cache_name;
|
||||
|
||||
@@ -81,7 +83,7 @@ class finder
|
||||
*
|
||||
* @param array $extensions A list of extensions that should be searched as well
|
||||
* @param bool $replace_list Should the list be emptied before adding the extensions
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function set_extensions(array $extensions, $replace_list = true)
|
||||
{
|
||||
@@ -101,7 +103,7 @@ class finder
|
||||
* Sets a core path to be searched in addition to extensions
|
||||
*
|
||||
* @param string $core_path The path relative to phpbb_root_path
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function core_path($core_path)
|
||||
{
|
||||
@@ -117,7 +119,7 @@ class finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $suffix A filename suffix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function suffix($suffix)
|
||||
{
|
||||
@@ -134,7 +136,7 @@ class finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $extension_suffix A filename suffix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_suffix($extension_suffix)
|
||||
{
|
||||
@@ -150,7 +152,7 @@ class finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $core_suffix A filename suffix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function core_suffix($core_suffix)
|
||||
{
|
||||
@@ -162,7 +164,7 @@ class finder
|
||||
* Sets the prefix all files found in extensions and core must match
|
||||
*
|
||||
* @param string $prefix A filename prefix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function prefix($prefix)
|
||||
{
|
||||
@@ -175,7 +177,7 @@ class finder
|
||||
* Sets a prefix all files found in extensions must match
|
||||
*
|
||||
* @param string $extension_prefix A filename prefix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_prefix($extension_prefix)
|
||||
{
|
||||
@@ -187,7 +189,7 @@ class finder
|
||||
* Sets a prefix all files found in the core path must match
|
||||
*
|
||||
* @param string $core_prefix A filename prefix
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function core_prefix($core_prefix)
|
||||
{
|
||||
@@ -202,7 +204,7 @@ class finder
|
||||
* the current directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function directory($directory)
|
||||
{
|
||||
@@ -215,7 +217,7 @@ class finder
|
||||
* Sets a directory all files found in extensions must be contained in
|
||||
*
|
||||
* @param string $extension_directory
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_directory($extension_directory)
|
||||
{
|
||||
@@ -227,7 +229,7 @@ class finder
|
||||
* Sets a directory all files found in the core path must be contained in
|
||||
*
|
||||
* @param string $core_directory
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
* @return \phpbb\finder\finder This object for chaining calls
|
||||
*/
|
||||
public function core_directory($core_directory)
|
||||
{
|
||||
@@ -424,7 +426,7 @@ class finder
|
||||
$this->query['is_dir'] = $is_dir;
|
||||
$query = md5(serialize($this->query) . serialize($extensions));
|
||||
|
||||
if (!defined('DEBUG') && $cache && isset($this->cached_queries[$query]))
|
||||
if (!$this->not_use_cache && $cache && isset($this->cached_queries[$query]))
|
||||
{
|
||||
return $this->cached_queries[$query];
|
||||
}
|
@@ -45,6 +45,11 @@ class create_schema_file extends \phpbb\install\task_base
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $not_use_cache;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -58,7 +63,8 @@ class create_schema_file extends \phpbb\install\task_base
|
||||
\phpbb\install\helper\database $db_helper,
|
||||
\phpbb\filesystem\filesystem_interface $filesystem,
|
||||
$phpbb_root_path,
|
||||
$php_ext)
|
||||
$php_ext,
|
||||
$not_use_cache)
|
||||
{
|
||||
$dbms = $db_helper->get_available_dbms($config->get('dbms'));
|
||||
$dbms = $dbms[$config->get('dbms')]['DRIVER'];
|
||||
@@ -78,6 +84,7 @@ class create_schema_file extends \phpbb\install\task_base
|
||||
$this->filesystem = $filesystem;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->not_use_cache = $not_use_cache;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
@@ -117,7 +124,7 @@ class create_schema_file extends \phpbb\install\task_base
|
||||
include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
|
||||
}
|
||||
|
||||
$finder = new \phpbb\finder($this->phpbb_root_path, null, $this->php_ext);
|
||||
$finder = new \phpbb\finder\finder(null, true, $this->phpbb_root_path, $this->php_ext);
|
||||
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($this->db, true);
|
||||
|
Reference in New Issue
Block a user