Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit db54130

Browse files
committed
fix an issue when view cache option is null or empty
1 parent 4e601a4 commit db54130

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Cache/ClearViewData.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ protected function execute(InputInterface $input, OutputInterface $output) : voi
2929
$config = $this->container->get('config');
3030
$viewCachePath = $config['view'][$config['view']['type']]['cache'];
3131
$output->writeln('Files under '.$viewCachePath .' will be deleted.');
32-
$cachedViewFileFolders = glob($viewCachePath.'/*');
33-
foreach ($cachedViewFileFolders as $folder) {
34-
$files = glob($folder.'/*');
35-
$output->writeln('Files under '.$folder .' will be deleted.');
36-
foreach ($files as $file) {
37-
$unlinkResult = file_exists($file)
38-
? (unlink($file) === true) ? 'deleted.':'could\'t deleted'
39-
:' file does not exist';
40-
$output->writeln($file . ' ' . $unlinkResult);
32+
if ( (string) $viewCachePath !== '') {
33+
$cachedViewFileFolders = glob($viewCachePath . '/*');
34+
foreach ($cachedViewFileFolders as $folder) {
35+
$files = glob($folder . '/*');
36+
$output->writeln('Files under ' . $folder . ' will be deleted.');
37+
foreach ($files as $file) {
38+
$unlinkResult = file_exists($file)
39+
? (unlink($file) === true) ? 'deleted.' : 'could\'t deleted'
40+
: ' file does not exist';
41+
$output->writeln($file . ' ' . $unlinkResult);
42+
}
43+
rmdir($folder);
44+
$output->writeln($folder . ' emptied.');
4145
}
42-
rmdir($folder);
43-
$output->writeln($folder .' emptied.');
4446
}
4547
$output->writeln($viewCachePath .' emptied.');
4648

0 commit comments

Comments
 (0)