Fixed Purge successful message only working in Scheduler but broken in CLI and Admin (fixes #1935)

This commit is contained in:
Djamil Legato
2020-11-20 12:16:37 -08:00
parent 1f6c2f5a0a
commit 0a601f10c0
2 changed files with 12 additions and 4 deletions

View File

@@ -32,6 +32,7 @@
* Fixed updated media missing from media when editing Flex Object after page reload
* Fixed issue with `config-default@` breaking on set [#1972](https://github.com/getgrav/grav-plugin-admin/issues/1971)
* Escape titles in Flex pages list [flex-objects#84](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/84)
* Fixed Purge successful message only working in Scheduler but broken in CLI and Admin [#1935](https://github.com/getgrav/grav-plugin-admin/issues/1935)
# v1.7.0-rc.17
## 10/07/2020

View File

@@ -621,15 +621,22 @@ class Cache extends Getters
/**
* Static function to call as a scheduled Job to purge old Doctrine files
*
* @return void
* @param bool $echo
*
* @return string|void
*/
public static function purgeJob()
public static function purgeJob($echo = false)
{
/** @var Cache $cache */
$cache = Grav::instance()['cache'];
$deleted_folders = $cache->purgeOldCache();
$msg = 'Purged ' . $deleted_folders . ' old cache folders...';
echo 'Purged ' . $deleted_folders . ' old cache folders...';
if ($echo) {
echo $msg;
} else {
return $msg;
}
}
/**
@@ -661,7 +668,7 @@ class Cache extends Getters
$name = 'cache-purge';
$logs = 'logs/' . $name . '.out';
$job = $scheduler->addFunction('Grav\Common\Cache::purgeJob', [], $name);
$job = $scheduler->addFunction('Grav\Common\Cache::purgeJob', [true], $name);
$job->at($at);
$job->output($logs);
$job->backlink('/config/system#caching');