Skip to content

Commit 71ff04e

Browse files
committed
Delete symfony container cache in shutdown function.
1 parent 8cd9b58 commit 71ff04e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drufony.module

+13-11
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ function drufony_flush_caches() {
2020
$paths[] = Drufony::getContainer()->getParameter('kernel.cache_dir');
2121
}
2222

23-
foreach ($paths as $path) {
24-
if (is_dir($path)) {
25-
$dir = dir($path);
26-
while (($entry = $dir->read()) !== FALSE) {
27-
if ($entry === '.' || $entry === '..') {
28-
continue;
23+
register_shutdown_function(function ($paths) {
24+
foreach ($paths as $path) {
25+
if (is_dir($path)) {
26+
$dir = dir($path);
27+
while (($entry = $dir->read()) !== FALSE) {
28+
if ($entry === '.' || $entry === '..') {
29+
continue;
30+
}
31+
$entry_path = $dir->path . DIRECTORY_SEPARATOR . $entry;
32+
file_unmanaged_delete_recursive($entry_path);
2933
}
30-
$entry_path = $dir->path . DIRECTORY_SEPARATOR . $entry;
31-
file_unmanaged_delete_recursive($entry_path);
34+
$dir->close();
3235
}
33-
$dir->close();
3436
}
35-
}
37+
}, $paths);
3638
return array();
3739
}
3840

@@ -54,4 +56,4 @@ if (!function_exists('composer_manager_register_autoloader')) {
5456
function composer_manager_register_autoloader() {
5557
require_once DRUPAL_ROOT . '/../vendor/autoload.php';
5658
}
57-
}
59+
}

0 commit comments

Comments
 (0)