mirror of
https://github.com/getgrav/grav.git
synced 2026-07-08 13:52:37 +02:00
Better error handling in cache clear
Added new parameter `remove` for `onBeforeCacheClear` event
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
# v1.1.9-rc.4
|
||||
## XX/XX/2016
|
||||
|
||||
1. [](#improved)
|
||||
* Better error handling in cache clear
|
||||
1. [](#bugfix)
|
||||
* Added new parameter `remove` for `onBeforeCacheClear` event
|
||||
|
||||
# v1.1.9-rc.3
|
||||
## 12/07/2016
|
||||
|
||||
|
||||
@@ -357,37 +357,37 @@ class Cache extends Getters
|
||||
}
|
||||
|
||||
// Clearing cache event to add paths to clear
|
||||
Grav::instance()->fireEvent('onBeforeCacheClear', new Event(['paths' => &$remove_paths]));
|
||||
Grav::instance()->fireEvent('onBeforeCacheClear', new Event(['remove' => $remove, 'paths' => &$remove_paths]));
|
||||
|
||||
foreach ($remove_paths as $stream) {
|
||||
|
||||
// Convert stream to a real path
|
||||
try {
|
||||
$path = $locator->findResource($stream, true, true);
|
||||
} catch (\Exception $e) {
|
||||
// stream not found..
|
||||
continue;
|
||||
}
|
||||
|
||||
$anything = false;
|
||||
$files = glob($path . '/*');
|
||||
$anything = false;
|
||||
$files = glob($path . '/*');
|
||||
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
if (@unlink($file)) {
|
||||
$anything = true;
|
||||
}
|
||||
} elseif (is_dir($file)) {
|
||||
if (Folder::delete($file)) {
|
||||
$anything = true;
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
if (@unlink($file)) {
|
||||
$anything = true;
|
||||
}
|
||||
} elseif (is_dir($file)) {
|
||||
if (Folder::delete($file)) {
|
||||
$anything = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($anything) {
|
||||
$output[] = '<red>Cleared: </red>' . $path . '/*';
|
||||
if ($anything) {
|
||||
$output[] = '<red>Cleared: </red>' . $path . '/*';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// stream not found or another error while deleting files.
|
||||
$output[] = '<red>ERROR: </red>' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user