A patch to lib/WikiDB.php follows. This is part 1 of my previous set of fixes to the caching logic.
This patch ensures that the _pagedata_cache is only updated when the data is read from the database. Without this patch, there is
the possibility that _pagedata_cache will be updated (correctly) due to user action and then later the update will be overwritten
with stale data from the _versiondata_cache. Also fixes some indenting.
Index: WikiDB.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB.php,v
retrieving revision 1.124
diff -u -r1.124 WikiDB.php
--- WikiDB.php 29 Jan 2005 20:43:32 -0000 1.124
+++ WikiDB.php 31 Jan 2005 14:52:19 -0000
@@ -2045,8 +2045,9 @@
}
function get_versiondata($pagename, $version, $need_content = false) {
+ $lastestpagedata = false;
// FIXME: Seriously ugly hackage
- if (USECACHE) { //temporary - for debugging
+ if (USECACHE) { //temporary - for debugging
assert(is_string($pagename) && $pagename != '');
// there is a bug here somewhere which results in an assertion failure at line 105
// of ArchiveCleaner.php It goes away if we use the next line.
@@ -2057,16 +2058,18 @@
!(is_array ($cache[$pagename])) || !(is_array ($cache[$pagename][$version]))) {
$cache[$pagename][$version][$nc] =
$this->_backend->get_versiondata($pagename, $version, $need_content);
+ $lastestpagedata = true;
// If we have retrieved all data, we may as well set the cache for $need_content = false
if ($need_content){
$cache[$pagename][$version]['0'] =& $cache[$pagename][$version]['1'];
}
}
$vdata = $cache[$pagename][$version][$nc];
- } else {
+ } else {
$vdata = $this->_backend->get_versiondata($pagename, $version, $need_content);
- }
- if ($vdata && !empty($vdata['%pagedata'])) {
+ $lastestpagedata = true;
+ }
+ if ($lastestpagedata && $vdata && !empty($vdata['%pagedata'])) {
$this->_pagedata_cache[$pagename] =& $vdata['%pagedata'];
}
return $vdata;
|