From cd00a03445c6b5dcdaba4631150c3c7e1370f526 Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Thu, 7 Dec 2006 02:10:05 +0100 Subject: recache and uncache the last_change from metadata The most recent changelog entry is already cached in the metadata as 'last_change' to avoid reading the page changelog on every request. - Recache the last change if it is missing and still valid. This is needed for when the metadata has been rerendered. - Uncaches the last change when it has been invalidated by an external edit. Ensures that external edits are not credited to the wrong author. darcs-hash:20061207011005-05dcb-3b1749f6626d07c4cc3de9587c45765423e2e4d9.gz --- inc/common.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 8ca29b918..26a0526b8 100644 --- a/inc/common.php +++ b/inc/common.php @@ -128,7 +128,22 @@ function pageinfo(){ if($REV){ $revinfo = getRevisionInfo($ID, $REV, 1024); }else{ - $revinfo = isset($info['meta']['last_change']) ? $info['meta']['last_change'] : getRevisionInfo($ID,$info['lastmod'],1024); + if (isset($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } + else { + $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); + // cache most recent changelog line in metadata if missing and still valid + if ($revinfo!==false) { + $info['meta']['last_change'] = $revinfo; + p_set_metadata($ID, array('last_change' => $revinfo)); + } + } + } + //and check for an external edit + if($revinfo!==false && $revinfo['date']!=$info['lastmod']){ + // cached changelog line no longer valid + $revinfo = false; + $info['meta']['last_change'] = $revinfo; + p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; -- cgit v1.2.3