summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/cache.php31
-rw-r--r--inc/parserutils.php23
2 files changed, 25 insertions, 29 deletions
diff --git a/inc/cache.php b/inc/cache.php
index 571b314cd..ff78e37ae 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -197,18 +197,6 @@ class cache_parser extends cache {
}
class cache_renderer extends cache_parser {
-
- function useCache($depends=array()) {
- $use = parent::useCache($depends);
-
- // meta data needs to be kept in step with the cache
- if (!$use && isset($this->page)) {
- p_set_metadata($this->page,array(),true);
- }
-
- return $use;
- }
-
function _useCache() {
global $conf;
@@ -251,19 +239,12 @@ class cache_renderer extends cache_parser {
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
-
- $valid = p_get_metadata($this->page, 'date valid');
- if (!empty($valid['age'])) {
- $this->depends['age'] = isset($this->depends['age']) ?
- min($this->depends['age'],$valid['age']) : $valid['age'];
- }
-
- } else {
- $this->depends['purge'] = true; // ... purging cache will generate metadata
- return;
+ $files[] = $metafile; // ... the page's own metadata
+
+ $valid = p_get_metadata($this->page, 'date valid'); // for xhtml this will render the metadata if needed
+ if (!empty($valid['age'])) {
+ $this->depends['age'] = isset($this->depends['age']) ?
+ min($this->depends['age'],$valid['age']) : $valid['age'];
}
}
diff --git a/inc/parserutils.php b/inc/parserutils.php
index a50e3f4f3..d4f55a6e4 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -221,6 +221,7 @@ function p_get_instructions($text){
* returns the metadata of a page
*
* @author Esther Brunner <esther@kaffeehaus.ch>
+ * @author Michael Hamann <michael@content-space.de>
*/
function p_get_metadata($id, $key='', $render=false){
global $ID;
@@ -231,10 +232,24 @@ function p_get_metadata($id, $key='', $render=false){
$cache = ($ID == $id);
$meta = p_read_metadata($id, $cache);
- // metadata has never been rendered before - do it! (but not for non-existent pages)
- if ($render && !isset($meta['current']['description']['abstract']) && page_exists($id)){
- $meta = p_render_metadata($id, $meta);
- p_save_metadata($id, $meta);
+ // prevent recursive calls in the cache
+ static $recursion = false;
+ if (!$recursion){
+ $recursion = true;
+
+ $cachefile = new cache_renderer($id, wikiFN($id), 'metadata');
+
+ if (page_exists($id) && !$cachefile->useCache()){
+ $meta = p_render_metadata($id, $meta);
+ if (p_save_metadata($id, $meta)) {
+ // store a timestamp in order to make sure that the cachefile is touched
+ $cachefile->storeCache(time());
+ } else {
+ msg('Unable to save metadata file. Hint: disk full; file permissions; safe_mode setting.',-1);
+ }
+ }
+
+ $recursion = false;
}
$val = $meta['current'];