diff options
author | Ben Coburn <btcoburn@silicodon.net> | 2006-12-07 02:10:05 +0100 |
---|---|---|
committer | Ben Coburn <btcoburn@silicodon.net> | 2006-12-07 02:10:05 +0100 |
commit | cd00a03445c6b5dcdaba4631150c3c7e1370f526 (patch) | |
tree | 156fa9d862a7a71661fb51e175720e679ee6ac48 /inc/common.php | |
parent | 6102af7d967d5365ad2e6d7ca40bedbf30deac50 (diff) | |
download | rpg-cd00a03445c6b5dcdaba4631150c3c7e1370f526.tar.gz rpg-cd00a03445c6b5dcdaba4631150c3c7e1370f526.tar.bz2 |
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
Diffstat (limited to 'inc/common.php')
-rw-r--r-- | inc/common.php | 17 |
1 files changed, 16 insertions, 1 deletions
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']; |