Migrate cache purge function to a proper class
And update dependencies and tests. Note that SESSION['tags'] has been removed a log ago
This commit is contained in:
parent
485b168a96
commit
b0428aa9b0
9 changed files with 76 additions and 68 deletions
application/feed
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Cache utilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Purges all cached pages
|
||||
*
|
||||
* @param string $pageCacheDir page cache directory
|
||||
*
|
||||
* @return mixed an error string if the directory is missing
|
||||
*/
|
||||
function purgeCachedPages($pageCacheDir)
|
||||
{
|
||||
if (! is_dir($pageCacheDir)) {
|
||||
$error = sprintf(t('Cannot purge %s: no directory'), $pageCacheDir);
|
||||
error_log($error);
|
||||
return $error;
|
||||
}
|
||||
|
||||
array_map('unlink', glob($pageCacheDir.'/*.cache'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates caches when the database is changed or the user logs out.
|
||||
*
|
||||
* @param string $pageCacheDir page cache directory
|
||||
*/
|
||||
function invalidateCaches($pageCacheDir)
|
||||
{
|
||||
// Purge cache attached to session.
|
||||
if (isset($_SESSION['tags'])) {
|
||||
unset($_SESSION['tags']);
|
||||
}
|
||||
|
||||
// Purge page cache shared by sessions.
|
||||
purgeCachedPages($pageCacheDir);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue