summaryrefslogtreecommitdiff
path: root/inc/parserutils.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2010-11-22 21:12:02 +0100
committerMichael Hamann <michael@content-space.de>2010-11-22 21:21:52 +0100
commit98214867894eba512bf47cba3439ccba3968f49b (patch)
tree5b6d8c550180d8a6e0f7962a643182e31e85a27c /inc/parserutils.php
parent5e1ee188750eca4ed2f13227ede216598c9669c8 (diff)
downloadrpg-98214867894eba512bf47cba3439ccba3968f49b.tar.gz
rpg-98214867894eba512bf47cba3439ccba3968f49b.tar.bz2
Render metadata when needed
This changes fundamentally when metadata is rendered. This commit introduces a new cache file for every page that just contains a timestamp and is updated whenever the metadata of that page is rendered. Metadata is rendered when p_get_metadata is called and the last rendering has been before a page, metadata, configuration or renderer update or purge is set like in the xhtml renderer cache. Metadata is no longer automatically rendered when the xhtml renderer cache isn't used but will still be rendered when needed as p_get_metadata is called in the cache. Metadata is also no longer rendered in the indexer script when missing as that is already done by pageinfo() before anything else is done so the indexer script won't be called when there is no metadata file.
Diffstat (limited to 'inc/parserutils.php')
-rw-r--r--inc/parserutils.php23
1 files changed, 19 insertions, 4 deletions
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'];