mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-24 08:10:13 +02:00
Merge pull request #1563 from cyberalien/ticket/11688
[ticket/11688] Purge TWIG cache
This commit is contained in:
commit
d536a69e29
70
phpBB/phpbb/cache/driver/file.php
vendored
70
phpBB/phpbb/cache/driver/file.php
vendored
@ -205,28 +205,34 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
|||||||
function purge()
|
function purge()
|
||||||
{
|
{
|
||||||
// Purge all phpbb cache files
|
// Purge all phpbb cache files
|
||||||
$dir = @opendir($this->cache_dir);
|
try
|
||||||
|
{
|
||||||
if (!$dir)
|
$iterator = new DirectoryIterator($this->cache_dir);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (($entry = readdir($dir)) !== false)
|
foreach ($iterator as $fileInfo)
|
||||||
{
|
{
|
||||||
if (strpos($entry, 'container_') !== 0 &&
|
if ($fileInfo->isDot())
|
||||||
strpos($entry, 'url_matcher') !== 0 &&
|
|
||||||
strpos($entry, 'sql_') !== 0 &&
|
|
||||||
strpos($entry, 'data_') !== 0 &&
|
|
||||||
strpos($entry, 'ctpl_') !== 0 &&
|
|
||||||
strpos($entry, 'tpl_') !== 0)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$filename = $fileInfo->getFilename();
|
||||||
$this->remove_file($this->cache_dir . $entry);
|
if ($fileInfo->isDir())
|
||||||
|
{
|
||||||
|
$this->remove_dir($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
elseif (strpos($filename, 'container_') === 0 ||
|
||||||
|
strpos($filename, 'url_matcher') === 0 ||
|
||||||
|
strpos($filename, 'sql_') === 0 ||
|
||||||
|
strpos($filename, 'data_') === 0)
|
||||||
|
{
|
||||||
|
$this->remove_file($fileInfo->getPathname());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir($dir);
|
|
||||||
|
|
||||||
unset($this->vars);
|
unset($this->vars);
|
||||||
unset($this->var_expires);
|
unset($this->var_expires);
|
||||||
@ -241,6 +247,44 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
|||||||
$this->is_modified = false;
|
$this->is_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove directory
|
||||||
|
*
|
||||||
|
* @param string $dir Directory to remove
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
protected function remove_dir($dir)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$iterator = new DirectoryIterator($dir);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($iterator as $fileInfo)
|
||||||
|
{
|
||||||
|
if ($fileInfo->isDot())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fileInfo->isDir())
|
||||||
|
{
|
||||||
|
$this->remove_dir($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->remove_file($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@rmdir($dir);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy cache data
|
* Destroy cache data
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user