diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cache.php | 29 | ||||
-rw-r--r-- | inc/common.php | 6 | ||||
-rw-r--r-- | inc/parser/metadata.php | 10 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 2 |
4 files changed, 36 insertions, 11 deletions
diff --git a/inc/cache.php b/inc/cache.php index ae27f4e9e..767ad8a35 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -36,6 +36,7 @@ class cache { * @param array $depends array of cache dependencies, support dependecies: * 'age' => max age of the cache in seconds * 'files' => cache must be younger than mtime of each file + * (nb. dependency passes if file doesn't exist) * * @return bool true if cache can be used, false otherwise */ @@ -218,14 +219,21 @@ class cache_renderer extends cache_parser { if (!parent::_useCache()) return false; - // for wiki pages, check for internal link status changes + // for wiki pages, check metadata dependencies if (isset($this->page)) { + $metadata = p_get_metadata($this->page); - // check the purgefile + // page has an expiry time, after which it should be re-rendered (RSS feeds use this) + $page_expiry = $metadata['date']['valid']['end']; + if (!empty($page_expiry) && (time() > $page_expiry)) return false; + + // check currnent link existence is consistent with cache version + // first check the purgefile // - if the cache is more recent that the purgefile we know no links can have been updated if ($this->_time < @filemtime($conf['cachedir'].'/purgefile')) { - $links = p_get_metadata($this->page,"relation references"); +# $links = p_get_metadata($this->page,"relation references"); + $links = $metadata['relation']['references']; if (!empty($links)) { foreach ($links as $id => $exists) { @@ -242,9 +250,20 @@ class cache_renderer extends cache_parser { // renderer cache file dependencies ... $files = array( - DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer + DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer ); - if (isset($this->page)) { $files[] = metaFN($this->page,'.meta'); } // ... the page's own metadata + + // page implies metadata and possibly some other dependencies + if (isset($this->page)) { + $metafile = metaFN($this->page,'.meta'); + if (@file_exists($metafile)) { + $files[] = $metafile; // ... the page's own metadata + $files[] = DOKU_INC.'inc/parser/metadata.php'; // ... the metadata renderer + } else { + $this->depends['purge'] = true; // ... purging cache will generate metadata + return; + } + } $this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files; parent::_addDependencies(); diff --git a/inc/common.php b/inc/common.php index 9a3cd6d8b..c2a6903ab 100644 --- a/inc/common.php +++ b/inc/common.php @@ -722,10 +722,8 @@ function saveWikiText($id,$text,$summary,$minor=false){ notify($id,'admin',$old,$summary,$minor); notify($id,'subscribers',$old,$summary,$minor); - //purge cache on add by updating the purgefile - if($conf['purgeonadd'] && (!$old || $del)){ - io_saveFile($conf['cachedir'].'/purgefile',time()); - } + // update the purgefile (timestamp of the last time anything within the wiki was changed) + io_saveFile($conf['cachedir'].'/purgefile',time()); } /** diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index fea2d48f2..9704c0475 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -325,7 +325,15 @@ class Doku_Renderer_metadata extends Doku_Renderer { if ($this->capture && $title) $this->doc .= '['.$title.']'; } - function rss($url){} + function rss($url,$params) { + global $conf; + + $this->meta['relation']['haspart'][$url] = true; + $this->meta['date']['valid']['end'] = + empty($this->meta['date']['valid']['end']) ? + time() + $conf['rss_update'] : + min($this->meta['date']['valid']['end'], time() + $conf['rss_update']); + } function table_open($maxcols = NULL, $numrows = NULL){} function table_close(){} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index c805dae70..c56367f47 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -502,7 +502,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //keep hash anchor - list($id,$hash) = split('#',$id,2); + list($id,$hash) = explode('#',$id,2); //prepare for formating $link['target'] = $conf['target']['wiki']; |