Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Deliberately clear partial cache blocks on flush (fixes #1383)
Move property to top of class definition Move property to top of class definition
- Loading branch information
1 parent
b58d42f
commit 48eb0e6
Showing
3 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -571,6 +571,16 @@ class SSViewer implements Flushable { | |
*/ | ||
private static $source_file_comments = false; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
private static $template_cache_flushed = false; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
private static $cacheblock_cache_flushed = false; | ||
|
||
/** | ||
* Set whether HTML comments indicating the source .SS file used to render this page should be | ||
* included in the output. This is enabled by default | ||
|
@@ -643,6 +653,7 @@ public static function get_source_file_comments() { | |
*/ | ||
public static function flush() { | ||
self::flush_template_cache(); | ||
self::flush_cacheblock_cache(); | ||
} | ||
|
||
/** | ||
|
@@ -907,24 +918,33 @@ public static function getTemplateFileByType($identifier, $type) { | |
return $founds[0]; | ||
} | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
static private $flushed = false; | ||
|
||
/** | ||
* Clears all parsed template files in the cache folder. | ||
* | ||
* Can only be called once per request (there may be multiple SSViewer instances). | ||
*/ | ||
public static function flush_template_cache() { | ||
if (!self::$flushed) { | ||
if (!self::$template_cache_flushed) { | ||
$dir = dir(TEMP_FOLDER); | ||
while (false !== ($file = $dir->read())) { | ||
if (strstr($file, '.cache')) unlink(TEMP_FOLDER . '/' . $file); | ||
} | ||
self::$flushed = true; | ||
self::$template_cache_flushed = true; | ||
} | ||
} | ||
|
||
/** | ||
* Clears all partial cache blocks. | ||
* | ||
* Can only be called once per request (there may be multiple SSViewer instances). | ||
*/ | ||
public static function flush_cacheblock_cache() { | ||
if (!self::$cacheblock_cache_flushed) { | ||
$cache = SS_Cache::factory('cacheblock'); | ||
$tags = $cache->getTags(); | ||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, $tags); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kinglozzer
Author
Member
|
||
self::$cacheblock_cache_flushed = true; | ||
} | ||
} | ||
|
||
|
Hrm. This seems to break if you're using a backend like APC.
Zend_Cache_Exception: tags are not supported by the current backend
. We need to find a way to make that work still. Maybe it just clears out everything if the backend doesn't support tags?