From 06ecb62abd5b1bee7ec25094e56968e28d2a29bf Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 6 May 2014 16:50:18 +0200 Subject: [ticket/12507] Add console command to purge the cache PHPBB3-12507 --- phpBB/bin/phpbbcli.php | 1 + phpBB/config/console.yml | 11 +++++ phpBB/phpbb/console/command/cache/purge.php | 62 +++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 phpBB/phpbb/console/command/cache/purge.php diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index 02d6b88943..a29990c3f2 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -33,6 +33,7 @@ $phpbb_class_loader_ext->register(); $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, "$phpbb_root_path/config"); $phpbb_container->get('request')->enable_super_globals(); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); +require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); $application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION); $application->register_container_commands($phpbb_container); diff --git a/phpBB/config/console.yml b/phpBB/config/console.yml index 3d57c257dd..1340d9c0d7 100644 --- a/phpBB/config/console.yml +++ b/phpBB/config/console.yml @@ -1,4 +1,15 @@ services: + console.command.cache.purge: + class: phpbb\console\command\cache\purge + arguments: + - @cache.driver + - @dbal.conn + - @auth + - @log + - @user + tags: + - { name: console.command } + console.command.config.delete: class: phpbb\console\command\config\delete arguments: diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php new file mode 100644 index 0000000000..017bdc5144 --- /dev/null +++ b/phpBB/phpbb/console/command/cache/purge.php @@ -0,0 +1,62 @@ +cache = $cache; + $this->db = $db; + $this->auth = $auth; + $this->log = $log; + $this->user = $user; + $this->user->add_lang(array('acp/common')); + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('cache:purge') + ->setDescription('Purge the cache.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->cache->purge(); + + // Clear permissions + $this->auth->acl_clear_prefetch(); + phpbb_cache_moderators($this->db, $this->cache, $this->auth); + + $this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array()); + + $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS')); + } +} -- cgit v1.2.1