[ticket/12631] Rename finder.not_use_cache to finder.cache

PHPBB3-12631
This commit is contained in:
Rubén Calvo 2018-09-28 13:10:16 +02:00 committed by Marc Alexander
parent 9308764fae
commit d31e986815
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
13 changed files with 30 additions and 28 deletions

View file

@ -3,6 +3,6 @@ services:
class: phpbb\finder\factory class: phpbb\finder\factory
arguments: arguments:
- '@cache' - '@cache'
- '%finder.not_use_cache%' - '%finder.cache%'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'

View file

@ -27,4 +27,4 @@ core:
log_errors: true log_errors: true
finder: finder:
not_use_cache: true cache: false

View file

@ -8,7 +8,7 @@ services:
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'
- '%tables%' - '%tables%'
- '%finder.not_use_cache%' - '%finder.cache%'
tags: tags:
- { name: install_database_install, order: 1 } - { name: install_database_install, order: 1 }

View file

@ -43,7 +43,7 @@ require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register(); $phpbb_class_loader->register();
$finder = new \phpbb\finder\finder(null, true, $phpbb_root_path, $phpEx); $finder = new \phpbb\finder\finder(null, false, $phpbb_root_path, $phpEx);
$classes = $finder->core_path('phpbb/') $classes = $finder->core_path('phpbb/')
->directory('/db/migration/data') ->directory('/db/migration/data')
->get_classes(); ->get_classes();

View file

@ -67,7 +67,7 @@ class container_configuration implements ConfigurationInterface
->arrayNode('finder') ->arrayNode('finder')
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()
->booleanNode('not_use_cache')->defaultValue(false)->end() ->booleanNode('cache')->defaultValue(true)->end()
->end() ->end()
->end() ->end()
->end() ->end()

View file

@ -19,23 +19,22 @@ namespace phpbb\finder;
class factory class factory
{ {
protected $cache; protected $cache;
protected $not_use_cache; protected $use_cache;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $php_ext; protected $php_ext;
/** /**
* Creates a new finder instance with its dependencies * 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 \phpbb\cache\service $cache A cache instance or null
* @param bool $not_use_cache Use cache or not
* @param string $phpbb_root_path Path to the phpbb root directory
* @param string $php_ext php file extension * @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) public function __construct(/*\phpbb\cache\service */ $cache, $use_cache, $phpbb_root_path, $php_ext)
{ {
$this->cache = $cache; $this->cache = $cache;
$this->not_use_cache = $not_use_cache; $this->use_cache = $use_cache;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
} }
@ -44,10 +43,12 @@ class factory
* The cache variable name used to store $this->cached_queries in $this->cache. * 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. * Allows the use of multiple differently configured finders with the same cache.
* @var string *
* @param string $cache_name The name of the cache variable, defaults to
* _ext_finder
*/ */
public function get($cache_name = '_ext_finder') 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); return new finder($this->cache, $this->use_cache, $this->phpbb_root_path, $this->php_ext, $cache_name);
} }
} }

View file

@ -23,7 +23,7 @@ class finder
protected $extensions; protected $extensions;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $cache; protected $cache;
protected $not_use_cache; protected $use_cache;
protected $php_ext; protected $php_ext;
/** /**
@ -56,11 +56,11 @@ class finder
* @param string $cache_name The name of the cache variable, defaults to * @param string $cache_name The name of the cache variable, defaults to
* _ext_finder * _ext_finder
*/ */
public function __construct(/*\phpbb\cache\service */ $cache, $not_use_cache, $phpbb_root_path, $php_ext, $cache_name = '_ext_finder') public function __construct(/*\phpbb\cache\service */ $cache, $use_cache, $phpbb_root_path, $php_ext, $cache_name = '_ext_finder')
{ {
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->cache = $cache; $this->cache = $cache;
$this->not_use_cache = $not_use_cache; $this->use_cache = $use_cache;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->cache_name = $cache_name; $this->cache_name = $cache_name;
@ -426,7 +426,7 @@ class finder
$this->query['is_dir'] = $is_dir; $this->query['is_dir'] = $is_dir;
$query = md5(serialize($this->query) . serialize($extensions)); $query = md5(serialize($this->query) . serialize($extensions));
if (!$this->not_use_cache && $cache && isset($this->cached_queries[$query])) if ($this->use_cache && $cache && isset($this->cached_queries[$query]))
{ {
return $this->cached_queries[$query]; return $this->cached_queries[$query];
} }

View file

@ -48,7 +48,7 @@ class create_schema_file extends \phpbb\install\task_base
/** /**
* @var string * @var string
*/ */
protected $not_use_cache; protected $finder_cache;
/** /**
* Constructor * Constructor
@ -64,7 +64,7 @@ class create_schema_file extends \phpbb\install\task_base
\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\filesystem\filesystem_interface $filesystem,
$phpbb_root_path, $phpbb_root_path,
$php_ext, $php_ext,
$not_use_cache) $finder_cache)
{ {
$dbms = $db_helper->get_available_dbms($config->get('dbms')); $dbms = $db_helper->get_available_dbms($config->get('dbms'));
$dbms = $dbms[$config->get('dbms')]['DRIVER']; $dbms = $dbms[$config->get('dbms')]['DRIVER'];
@ -84,7 +84,7 @@ class create_schema_file extends \phpbb\install\task_base
$this->filesystem = $filesystem; $this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->not_use_cache = $not_use_cache; $this->finder_cache = $finder_cache;
parent::__construct(true); parent::__construct(true);
} }
@ -124,7 +124,7 @@ class create_schema_file extends \phpbb\install\task_base
include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
} }
$finder = new \phpbb\finder\finder(null, true, $this->phpbb_root_path, $this->php_ext); $finder = new \phpbb\finder\finder(null, $this->finder_cache, $this->phpbb_root_path, $this->php_ext);
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory(); $factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true); $db_tools = $factory->get($this->db, true);

View file

@ -243,7 +243,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
public function test_get_classes_create_cache() public function test_get_classes_create_cache()
{ {
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$finder = new \phpbb\finder\finder($cache, true, __DIR__ . '/', 'php', '_custom_cache_name'); $finder = new \phpbb\finder\finder($cache, false, __DIR__ . '/', 'php', '_custom_cache_name');
$finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
$files = $finder->suffix('_class.php')->get_files(); $files = $finder->suffix('_class.php')->get_files();
@ -288,7 +288,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
md5(serialize($query)) => array('file_name' => 'extension'), md5(serialize($query)) => array('file_name' => 'extension'),
), ),
)), )),
true, false,
__DIR__ . '/', __DIR__ . '/',
'_ext_finder' '_ext_finder'
); );

View file

@ -24,6 +24,7 @@ class phpbb_mock_container_builder implements ContainerInterface
$this->setParameter('session.log_errors', false); $this->setParameter('session.log_errors', false);
$this->setParameter('session.force_sid', true); $this->setParameter('session.force_sid', true);
$this->setParameter('finder.not_use_cache', false); $this->setParameter('finder.not_use_cache', false);
$this->setParameter('finder.cache', false);
} }
/** /**

View file

@ -24,6 +24,6 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->container = $container; $this->container = $container;
$this->config = new \phpbb\config\config(array()); $this->config = new \phpbb\config\config(array());
$this->user = new \phpbb\user($lang,'\phpbb\datetime'); $this->user = new \phpbb\user($lang,'\phpbb\datetime');
$this->finder_factory = new \phpbb\finder\factory(null, true, $this->phpbb_root_path, $phpEx); $this->finder_factory = new \phpbb\finder\factory(null, false, $this->phpbb_root_path, $phpEx);
} }
} }

View file

@ -74,7 +74,7 @@ abstract class phpbb_database_test_case extends TestCase
$setup_extensions = static::setup_extensions(); $setup_extensions = static::setup_extensions();
$finder = new \phpbb\finder\finder(null, true, $phpbb_root_path, $phpEx); $finder = new \phpbb\finder\finder(null, false, $phpbb_root_path, $phpEx);
$finder->core_path('phpbb/db/migration/data/'); $finder->core_path('phpbb/db/migration/data/');
if (!empty($setup_extensions)) if (!empty($setup_extensions))
{ {

View file

@ -365,7 +365,7 @@ class phpbb_database_test_connection_manager
{ {
global $phpbb_root_path, $phpEx, $table_prefix; global $phpbb_root_path, $phpEx, $table_prefix;
$finder = new \phpbb\finder\finder(null, true, $phpbb_root_path, $phpEx); $finder = new \phpbb\finder\finder(null, false, $phpbb_root_path, $phpEx);
$classes = $finder->core_path('phpbb/db/migration/data/') $classes = $finder->core_path('phpbb/db/migration/data/')
->get_classes(); ->get_classes();