diff --git a/utils/Commands/ClearcacheCommand.php b/utils/Commands/ClearcacheCommand.php index 0aae1c010..6d9842803 100644 --- a/utils/Commands/ClearcacheCommand.php +++ b/utils/Commands/ClearcacheCommand.php @@ -6,6 +6,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Question\ConfirmationQuestion; use Seeddms\Seeddms\Settings; use Seeddms\Seeddms\Translator; @@ -33,9 +35,10 @@ class ClearcacheCommand extends Command protected function configure() { $this->setName('cache:clear') - ->setDescription('Clears the cache') - ->setHelp('Clears all cache or those specified.') - ->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from cache.', null) + ->setDescription('Clear cache') + ->setHelp('Clears either all caches or those specified with option --cache. Think twice before you clear a cache with previews. Depending on the number of documents in your DMS, it may take a long time to recreate the cache.') + ->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from this cache.', null) + ->addOption('force', '', InputOption::VALUE_NONE, 'Force operation, do not ask') ; } @@ -52,6 +55,14 @@ class ClearcacheCommand extends Command return Command::FAILURE; } + if (!$input->getOption('force')) { + $helper = new QuestionHelper(); + $question = new ConfirmationQuestion('Do you really want to clear the cache? ', false); + if (!$helper->ask($input, $output, $question)) { + return Command::SUCCESS; + } + } + require_once('inc/inc.DBInit.php'); $post = array_flip($input->getOption('cache'));