summaryrefslogtreecommitdiff
path: root/inc/parserutils.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2008-05-02 15:02:34 +0200
committerAndreas Gohr <andi@splitbrain.org>2008-05-02 15:02:34 +0200
commit35fbe9ef32ad9f68bc0d7ff1b4c845c1b5458f85 (patch)
treed387e8493bcdb40763a2ced7947ce59653e5487c /inc/parserutils.php
parent859e5f0792fecf690ae464b3d95a6072d286f4f5 (diff)
downloadrpg-35fbe9ef32ad9f68bc0d7ff1b4c845c1b5458f85.tar.gz
rpg-35fbe9ef32ad9f68bc0d7ff1b4c845c1b5458f85.tar.bz2
correctly expire the cache for geshi highlighted strings
darcs-hash:20080502130234-7ad00-ddd191945f838db2cbdd6f6a0fda2a6e034a2205.gz
Diffstat (limited to 'inc/parserutils.php')
-rw-r--r--inc/parserutils.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/inc/parserutils.php b/inc/parserutils.php
index 323d6f766..4d77ece2f 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -630,26 +630,30 @@ function p_get_first_heading($id, $render=true){
* @param string $wrapper html element to wrap the returned highlighted text
*
* @author Christopher Smith <chris@jalakai.co.uk>
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
function p_xhtml_cached_geshi($code, $language, $wrapper='pre') {
global $conf;
+ $language = strtolower($language);
// remove any leading or trailing blank lines
$code = preg_replace('/^\s*?\n|\s*?\n$/','',$code);
$cache = getCacheName($language.$code,".code");
+ $ctime = @filemtime($cache);
- if (@file_exists($cache) && !$_REQUEST['purge'] &&
- (filemtime($cache) > filemtime(DOKU_INC . 'inc/geshi.php'))) {
+ if($ctime && !$_REQUEST['purge'] &&
+ $ctime > filemtime(DOKU_INC.'inc/geshi.php') &&
+ $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') &&
+ $ctime > filemtime(DOKU_CONF.'dokuwiki.php'){
$highlighted_code = io_readFile($cache, false);
- @touch($cache);
} else {
require_once(DOKU_INC . 'inc/geshi.php');
- $geshi = new GeSHi($code, strtolower($language), DOKU_INC . 'inc/geshi');
+ $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi');
$geshi->set_encoding('utf-8');
$geshi->enable_classes();
$geshi->set_header_type(GESHI_HEADER_PRE);