From 9dc25510a17fee408e140fecd175b47ae2e54f5f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Jan 2022 22:10:03 +0100 Subject: [PATCH 1/5] [ticket/16891] Add new method for deferring cache purge to end of request PHPBB3-16891 --- phpBB/config/default/container/services.yml | 1 + phpBB/phpbb/cache/service.php | 35 ++++++++++++++++++++- phpBB/phpbb/extension/manager.php | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml index 9e2af7df23..9562b8e02e 100644 --- a/phpBB/config/default/container/services.yml +++ b/phpBB/config/default/container/services.yml @@ -40,6 +40,7 @@ services: - '@cache.driver' - '@config' - '@dbal.conn' + - '@dispatcher' - '%core.root_path%' - '%core.php_ext%' diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 502ae27625..0b2e42b089 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -13,11 +13,20 @@ namespace phpbb\cache; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\KernelEvents; + /** * Class for grabbing/handling cached entries */ class service { + /** @var string Name of event used for cache purging */ + private const CACHE_PURGE_EVENT = 'core.garbage_collection'; + + /** @var bool Flag whether cache purge has been deferred */ + private $cache_purge_deferred = false; + /** * Cache driver. * @@ -39,6 +48,9 @@ class service */ protected $db; + /** @var \phpbb\event\dispatcher phpBB Event dispatcher */ + protected $dispatcher; + /** * Root path. * @@ -59,14 +71,16 @@ class service * @param \phpbb\cache\driver\driver_interface $driver The cache driver * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db Database connection + * @param \phpbb\event\dispatcher $dispatcher Event dispatcher * @param string $phpbb_root_path Root path * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\cache\driver\driver_interface $driver, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\cache\driver\driver_interface $driver, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher $dispatcher, $phpbb_root_path, $php_ext) { $this->set_driver($driver); $this->config = $config; $this->db = $db; + $this->dispatcher = $dispatcher; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -81,6 +95,25 @@ class service return $this->driver; } + /** + * Deferred purge of the cache. + * + * A deferred purge will be executed after rendering a page. + * It is recommended to be used in cases where an instant purge of the cache + * is not required, i.e. when the goal of a cache purge is to start from a + * clear cache at the next page load. + * + * @return void + */ + public function deferred_purge(): void + { + if (!$this->cache_purge_deferred) + { + $this->dispatcher->addListener(self::CACHE_PURGE_EVENT, [$this, 'purge']); + $this->cache_purge_deferred = true; + } + } + /** * Replaces the cache driver used by this cache service. * diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 1ce8425fff..0a9f00c77c 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -197,7 +197,7 @@ class manager if ($this->cache) { - $this->cache->purge(); + $this->cache->deferred_purge(); } } From 7992b3f4763c0cd3ad434f3990c5e9e69d1cbf49 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 28 Jan 2022 21:58:32 +0100 Subject: [PATCH 2/5] [ticket/16891] Update test files to work with changed cache service PHPBB3-16891 --- tests/attachment/upload_test.php | 4 ++-- tests/cache/common_test_case.php | 3 ++- tests/cache/dummy_driver_test.php | 3 ++- tests/dbal/migrator_tool_module_test.php | 4 ++-- tests/dbal/migrator_tool_permission_role_test.php | 3 ++- tests/dbal/migrator_tool_permission_test.php | 3 ++- tests/extension/manager_test.php | 3 ++- tests/extension/metadata_manager_test.php | 5 +++-- tests/notification/base.php | 4 ++-- tests/notification/notification_method_email_test.php | 4 ++-- tests/notification/submit_post_base.php | 7 ++++--- tests/notification/user_list_trim_test.php | 1 + tests/session/check_ban_test.php | 5 +++++ tests/test_framework/phpbb_functional_test_case.php | 5 +++-- tests/version/version_helper_remote_test.php | 3 ++- 15 files changed, 36 insertions(+), 21 deletions(-) diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index c26efd5094..f99d759ba9 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -81,7 +81,8 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $config = $this->config; $this->phpbb_root_path = $phpbb_root_path; $this->db = $this->new_dbal(); - $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx); + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $this->phpbb_dispatcher, $phpbb_root_path, $phpEx); $this->request = $this->createMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); @@ -136,7 +137,6 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case )); $this->factory = new \phpbb\files\factory($this->container); $this->files_upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); - $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $this->user = new \phpbb\user($this->language, '\phpbb\datetime'); $this->user->data['user_id'] = ANONYMOUS; diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index 64273c250a..0fb39d455d 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -74,7 +74,8 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case global $db, $cache, $phpbb_root_path, $phpEx; $config = new phpbb\config\config(array()); $db = $this->new_dbal(); - $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; diff --git a/tests/cache/dummy_driver_test.php b/tests/cache/dummy_driver_test.php index 09d33b0475..101eb3af41 100644 --- a/tests/cache/dummy_driver_test.php +++ b/tests/cache/dummy_driver_test.php @@ -50,7 +50,8 @@ class phpbb_cache_dummy_driver_test extends phpbb_database_test_case global $db, $cache, $phpbb_root_path, $phpEx; $config = new phpbb\config\config(array()); $db = $this->new_dbal(); - $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 7d192dfecf..e1d1971658 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -32,13 +32,13 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $skip_add_log = true; $db = $this->db = $this->new_dbal(); - $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $cache = new phpbb_mock_cache; - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $auth = $this->createMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/dbal/migrator_tool_permission_role_test.php b/tests/dbal/migrator_tool_permission_role_test.php index 48e45bf2d5..55bda8c0ce 100644 --- a/tests/dbal/migrator_tool_permission_role_test.php +++ b/tests/dbal/migrator_tool_permission_role_test.php @@ -64,7 +64,8 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_ parent::setup(); $db = $this->db = $this->new_dbal(); - $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); $this->auth = new \phpbb\auth\auth(); // Initialize this auth_admin instance later after adding new auth options via this->tool->add() diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 723eef2f0a..750fbcaa51 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -38,7 +38,8 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case parent::setup(); $db = $this->db = $this->new_dbal(); - $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); $this->auth = new \phpbb\auth\auth(); $this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 86e42b1794..41cfe8d366 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -155,6 +155,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case { $config = new \phpbb\config\config(array('version' => PHPBB_VERSION)); $db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($db); $phpbb_root_path = __DIR__ . './../../phpBB/'; @@ -185,7 +186,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case 'phpbb_ext', __DIR__ . '/', $php_ext, - ($with_cache) ? new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_root_path, $php_ext) : null + ($with_cache) ? new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_dispatcher, $phpbb_root_path, $php_ext) : null ); } } diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 682882c3fc..2357d593b5 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -40,12 +40,13 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case 'version' => '3.1.0', )); $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $factory = new \phpbb\db\tools\factory(); $this->db_tools = $factory->get($this->db); $this->phpbb_root_path = __DIR__ . '/'; $this->phpEx = 'php'; - $this->cache = new \phpbb\cache\service(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx); + $this->cache = new \phpbb\cache\service(new phpbb_mock_cache(), $this->config, $this->db, $phpbb_dispatcher, $this->phpbb_root_path, $this->phpEx); $this->table_prefix = 'phpbb_'; @@ -70,7 +71,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $cache_path, null, $loader, - new \phpbb\event\dispatcher($container), + $phpbb_dispatcher, array( 'cache' => false, 'debug' => false, diff --git a/tests/notification/base.php b/tests/notification/base.php index 980e43ce1e..26e2163e3b 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -79,17 +79,17 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->user = $user; $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $cache_driver = new \phpbb\cache\driver\dummy(); $cache = $this->cache = new \phpbb\cache\service( $cache_driver, $this->config, $this->db, + $this->phpbb_dispatcher, $phpbb_root_path, $phpEx ); - $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = $this->container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures')); $loader->load('services_notification.yml'); diff --git a/tests/notification/notification_method_email_test.php b/tests/notification/notification_method_email_test.php index 63e2dfb343..d778f2159d 100644 --- a/tests/notification/notification_method_email_test.php +++ b/tests/notification/notification_method_email_test.php @@ -58,17 +58,17 @@ class notification_method_email_test extends phpbb_tests_notification_base $this->user = $user; $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $cache_driver = new \phpbb\cache\driver\dummy(); $cache = $this->cache = new \phpbb\cache\service( $cache_driver, $this->config, $this->db, + $this->phpbb_dispatcher, $phpbb_root_path, $phpEx ); - $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = $this->container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures')); $loader->load('services_notification.yml'); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 1deef67d8f..80863eab8b 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -79,18 +79,19 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c 'allow_board_notifications' => true, )); + // Event dispatcher + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $cache_driver = new \phpbb\cache\driver\dummy(); $cache = new \phpbb\cache\service( $cache_driver, $config, $db, + $phpbb_dispatcher, $phpbb_root_path, $phpEx ); - // Event dispatcher - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - // Language $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 4ddfcb82cd..82f1429624 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -35,6 +35,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case new \phpbb\cache\driver\dummy(), $config, $db, + $phpbb_dispatcher, $phpbb_root_path, $phpEx ); diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 147274398d..7b0aac060c 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -58,6 +58,10 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case $phpbb_filesystem = new \phpbb\filesystem\filesystem(); $this->backup_cache = $cache; + + // Event dispatcher + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + // Change the global cache object for this test because // the mock cache object does not hit the database as is needed // for this test. @@ -65,6 +69,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case new \phpbb\cache\driver\file(), $config, $this->db, + $phpbb_dispatcher, $phpbb_root_path, $phpEx ); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7af65b5d5b..815312e236 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -253,8 +253,9 @@ class phpbb_functional_test_case extends phpbb_test_case array(), new \phpbb\db\migration\helper() ); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $container->set('migrator', $migrator); - $container->set('dispatcher', new phpbb_mock_event_dispatcher()); + $container->set('dispatcher', $phpbb_dispatcher); $extension_manager = new \phpbb\extension\manager( $container, @@ -264,7 +265,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'] . 'ext', __DIR__ . '/', $phpEx, - new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_root_path, $phpEx) + new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx) ); return $extension_manager; diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index 959fc5625c..762493986a 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -29,10 +29,11 @@ class version_helper_remote_test extends \phpbb_test_case 'version' => '3.1.0', )); $container = new \phpbb_mock_container_builder(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $db = new \phpbb\db\driver\factory($container); $this->cache = $this->getMockBuilder('\phpbb\cache\service') ->setMethods(array('get')) - ->setConstructorArgs(array(new \phpbb\cache\driver\dummy(), $config, $db, '../../', 'php')) + ->setConstructorArgs(array(new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_dispatcher, '../../', 'php')) ->getMock(); $this->cache->expects($this->any()) From 3be1e3029e5b36be80b1d858b69899fe046f77f1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 28 Jan 2022 22:04:21 +0100 Subject: [PATCH 3/5] [ticket/16891] Remove unused use statements PHPBB3-16891 --- phpBB/phpbb/cache/service.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 0b2e42b089..1e71e484a2 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -13,9 +13,6 @@ namespace phpbb\cache; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\HttpKernel\KernelEvents; - /** * Class for grabbing/handling cached entries */ From c4fcbc2cbde264035dae7557440e1ac434de0cb5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 28 Jan 2022 22:58:14 +0100 Subject: [PATCH 4/5] [ticket/16891] Add mock to purge extension manager cache in tests PHPBB3-16891 --- tests/test_framework/phpbb_functional_test_case.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 815312e236..a90008c22e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -256,6 +256,12 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $container->set('migrator', $migrator); $container->set('dispatcher', $phpbb_dispatcher); + $cache = $this->getMockBuilder('\phpbb\cache\service') + ->setConstructorArgs([$this->get_cache_driver(), $config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx]) + ->setMethods(['deferred_purge']) + ->getMock(); + $cache->method('deferred_purge') + ->willReturnCallback([$cache, 'purge']); $extension_manager = new \phpbb\extension\manager( $container, @@ -265,7 +271,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'] . 'ext', __DIR__ . '/', $phpEx, - new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx) + $cache ); return $extension_manager; From 5017dbd58d13f86d3318ad3096b3fee2f075b364 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 29 Jan 2022 08:51:56 +0100 Subject: [PATCH 5/5] [ticket/16891] Rename constant for event name of deferred purge PHPBB3-16891 --- phpBB/phpbb/cache/service.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 1e71e484a2..bb46dec419 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -19,7 +19,7 @@ namespace phpbb\cache; class service { /** @var string Name of event used for cache purging */ - private const CACHE_PURGE_EVENT = 'core.garbage_collection'; + private const PURGE_DEFERRED_ON_EVENT = 'core.garbage_collection'; /** @var bool Flag whether cache purge has been deferred */ private $cache_purge_deferred = false; @@ -106,7 +106,7 @@ class service { if (!$this->cache_purge_deferred) { - $this->dispatcher->addListener(self::CACHE_PURGE_EVENT, [$this, 'purge']); + $this->dispatcher->addListener(self::PURGE_DEFERRED_ON_EVENT, [$this, 'purge']); $this->cache_purge_deferred = true; } }