From d31e9868154c64dea6a16f8cf88f93829b176337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Fri, 28 Sep 2018 13:10:16 +0200 Subject: [PATCH] [ticket/12631] Rename finder.not_use_cache to finder.cache PHPBB3-12631 --- .../default/container/services_finder.yml | 2 +- phpBB/config/development/config.yml | 2 +- .../container/services_install_database.yml | 2 +- phpBB/develop/create_schema_files.php | 2 +- .../di/extension/container_configuration.php | 2 +- phpBB/phpbb/finder/factory.php | 21 ++++++++++--------- phpBB/phpbb/finder/finder.php | 8 +++---- .../task/create_schema_file.php | 8 +++---- tests/extension/finder_test.php | 4 ++-- tests/mock/container_builder.php | 1 + tests/mock/extension_manager.php | 2 +- .../phpbb_database_test_case.php | 2 +- ...phpbb_database_test_connection_manager.php | 2 +- 13 files changed, 30 insertions(+), 28 deletions(-) diff --git a/phpBB/config/default/container/services_finder.yml b/phpBB/config/default/container/services_finder.yml index 9937f35396..f42886df7f 100644 --- a/phpBB/config/default/container/services_finder.yml +++ b/phpBB/config/default/container/services_finder.yml @@ -3,6 +3,6 @@ services: class: phpbb\finder\factory arguments: - '@cache' - - '%finder.not_use_cache%' + - '%finder.cache%' - '%core.root_path%' - '%core.php_ext%' diff --git a/phpBB/config/development/config.yml b/phpBB/config/development/config.yml index fb96e5251c..37a690e036 100644 --- a/phpBB/config/development/config.yml +++ b/phpBB/config/development/config.yml @@ -27,4 +27,4 @@ core: log_errors: true finder: - not_use_cache: true + cache: false diff --git a/phpBB/config/installer/container/services_install_database.yml b/phpBB/config/installer/container/services_install_database.yml index 5f10ff0373..1ea5013ef1 100644 --- a/phpBB/config/installer/container/services_install_database.yml +++ b/phpBB/config/installer/container/services_install_database.yml @@ -8,7 +8,7 @@ services: - '%core.root_path%' - '%core.php_ext%' - '%tables%' - - '%finder.not_use_cache%' + - '%finder.cache%' tags: - { name: install_database_install, order: 1 } diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 912b681575..5288a84d6d 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -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->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/') ->directory('/db/migration/data') ->get_classes(); diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 4d23de22de..5e0c46b098 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -67,7 +67,7 @@ class container_configuration implements ConfigurationInterface ->arrayNode('finder') ->addDefaultsIfNotSet() ->children() - ->booleanNode('not_use_cache')->defaultValue(false)->end() + ->booleanNode('cache')->defaultValue(true)->end() ->end() ->end() ->end() diff --git a/phpBB/phpbb/finder/factory.php b/phpBB/phpbb/finder/factory.php index 21b568b735..3db960154f 100644 --- a/phpBB/phpbb/finder/factory.php +++ b/phpBB/phpbb/finder/factory.php @@ -19,23 +19,22 @@ namespace phpbb\finder; class factory { protected $cache; - protected $not_use_cache; + protected $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 + * @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 */ - 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->not_use_cache = $not_use_cache; + $this->use_cache = $use_cache; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -44,10 +43,12 @@ class factory * 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 + * + * @param string $cache_name The name of the cache variable, defaults to + * _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); } } diff --git a/phpBB/phpbb/finder/finder.php b/phpBB/phpbb/finder/finder.php index 80b98b5eff..5c88396299 100644 --- a/phpBB/phpbb/finder/finder.php +++ b/phpBB/phpbb/finder/finder.php @@ -23,7 +23,7 @@ class finder protected $extensions; protected $phpbb_root_path; protected $cache; - protected $not_use_cache; + protected $use_cache; protected $php_ext; /** @@ -56,11 +56,11 @@ class finder * @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, $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->cache = $cache; - $this->not_use_cache = $not_use_cache; + $this->use_cache = $use_cache; $this->php_ext = $php_ext; $this->cache_name = $cache_name; @@ -426,7 +426,7 @@ class finder $this->query['is_dir'] = $is_dir; $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]; } diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php index 1788271365..695ec86143 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php @@ -48,7 +48,7 @@ class create_schema_file extends \phpbb\install\task_base /** * @var string */ - protected $not_use_cache; + protected $finder_cache; /** * Constructor @@ -64,7 +64,7 @@ class create_schema_file extends \phpbb\install\task_base \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, - $not_use_cache) + $finder_cache) { $dbms = $db_helper->get_available_dbms($config->get('dbms')); $dbms = $dbms[$config->get('dbms')]['DRIVER']; @@ -84,7 +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; + $this->finder_cache = $finder_cache; 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); } - $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(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($this->db, true); diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 75d400269c..bd25b6caf9 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -243,7 +243,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_get_classes_create_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())); $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'), ), )), - true, + false, __DIR__ . '/', '_ext_finder' ); diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index db389929ed..1a02ded887 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -24,6 +24,7 @@ class phpbb_mock_container_builder implements ContainerInterface $this->setParameter('session.log_errors', false); $this->setParameter('session.force_sid', true); $this->setParameter('finder.not_use_cache', false); + $this->setParameter('finder.cache', false); } /** diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index e38b1a1b1e..31412559c3 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -24,6 +24,6 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager $this->container = $container; $this->config = new \phpbb\config\config(array()); $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); } } diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index deaee99cd1..2b1b8269f7 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -74,7 +74,7 @@ abstract class phpbb_database_test_case extends TestCase $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/'); if (!empty($setup_extensions)) { diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index fdc6736a80..d2e16b9006 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -365,7 +365,7 @@ class phpbb_database_test_connection_manager { 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/') ->get_classes();