From fc18c0fbae82b1bd3d6b74b486798753afea2c73 Mon Sep 17 00:00:00 2001 From: chris <chris@jalakai.co.uk> Date: Fri, 26 Jan 2007 21:41:45 +0100 Subject: [PATCH] fix FS#1010 darcs-hash:20070126204145-9b6ab-db7eba9c6045584a381eb83ae48787627973532b.gz --- inc/parser/metadata.php | 2 +- inc/parser/xhtml.php | 2 +- inc/parserutils.php | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index d818ac337..1bb14b674 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -401,7 +401,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { $isImage = false; if (is_null($title)){ if ($conf['useheading'] && $id){ - $heading = p_get_first_heading($id); + $heading = p_get_first_heading($id,false); if ($heading) return $heading; } return $default; diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 5e3a12849..7cccb14ec 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -995,7 +995,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $isImage = false; if ( is_null($title) ) { if ($conf['useheading'] && $id) { - $heading = p_get_first_heading($id); + $heading = p_get_first_heading($id,true); if ($heading) { return $this->_xmlEntities($heading); } diff --git a/inc/parserutils.php b/inc/parserutils.php index b5dbce4dd..68ccd3231 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -229,15 +229,14 @@ function p_get_metadata($id, $key=false, $render=false){ // accessed several times. This may catch a few other pages, but that shouldn't be an issue. $cache = ($ID == $id); $meta = p_read_metadata($id, $cache); - $file = metaFN($id, '.meta'); // metadata has never been rendered before - do it! - if ((!file_exists($file) && file_exists(wikiFN($id))) || ($render && !$meta['description']['abstract'])){ + if ($render && !$meta['description']['abstract']){ $meta = p_render_metadata($id, $meta); - io_saveFile($file, serialize($meta)); + io_saveFile(metaFN($id, '.meta'), serialize($meta)); // sync cached copies, including $INFO metadata - if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; + if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; } } @@ -559,11 +558,19 @@ function p_render($mode,$instructions,& $info){ /** * Gets the first heading from a file * + * @param string $id dokuwiki page id + * @param bool $render rerender if first heading not known + * default: false -- this protects against loops where $id requires a + * first heading further pages which eventually result + * in a request for a first heading from a page already + * in the chain (FS#1010) + * + * * @author Andreas Gohr <andi@splitbrain.org> */ -function p_get_first_heading($id){ +function p_get_first_heading($id, $render=false){ global $conf; - return $conf['useheading'] ? p_get_metadata($id,'title') : null; + return $conf['useheading'] ? p_get_metadata($id,'title',$render) : null; } /** -- GitLab