Reini,
I see that you committed 1 of the 3 different fixes included in my original
email. I did some further testing and found that my initial report of
remaining errors was due to html caching - now my test case works correctly.
The 2 other updates were:
Only update the _pagedata_cache if the database is queried
----------------------------------------------------------
(the 4 lines involving $readdata). This is important as if the _data_cache
has been updated due to user action, it might be overwritten with stale data
when get_versiondata is called later.
Change $nc (derived from $need_content) to use '1' and '2'
----------------------------------------------------------
If $nc is '0', I found weird stuff happening to _versiondata_cache
(referenced through $cache) and to _pagedata_cache when assigned from $vdata
which was assigned from _versiondata_cache (referenced through $cache). I
wrote the following debugging code and liberally called it in various places
in get_versiondata. For example, after the call to _backend->get_versiondata
it reported that $cache[$pagename][$version][$nc] existed but contained
nothing when $nc was '0'.
if (!defined('WIKIDB_FORCE_CREATE'))
define('WIKIDB_FORCE_CREATE', -1);
if (!defined('CJC_EL'))
define('CJC_EL','c:\amp\error.log');
if (!defined('CJC_LE'))
define('CJC_LE',"\r\n");
function log_var($logvar,$varname,$depth = 0) {
if (is_array($logvar)) {
$nameprint = 1;
reset($logvar);
while (list($k,$v) = each($logvar)) {
if ($k<>'content' && $k<>'%content') {
if ($nameprint) {
$nameprint = 0;
error_log(str_repeat('
',$depth*2).$varname.CJC_LE,3,CJC_EL);
}
if(is_array($v) && $depth < 10) {
log_var($v,$varname.'['.$k.']',$depth+1);
} else {
error_log(str_repeat('
',($depth+1)*2).$k.' => '.$v.CJC_LE,3,CJC_EL);
}
}
}
} else {
error_log(str_repeat(' ',$depth*2).$varname.':
'.$logvar.CJC_LE,3,CJC_EL);
}
}
Regards,
Charles
-----Original Message-----
From: Charles Corrigan [mailto:charles@...]
Sent: 17 January 2005 01:46
To: phpwiki-talk@...
Subject: [Phpwiki-talk] Fixes to caching
These changes do not completely fix caching but do make an improvement.
1 - Change the owner of page RichTablePlugin to the administrator
2 - Open PhpWikiAdministration/Chown for *. Result: I still see page
RichTablePlugin with owner ReiniUrban.
3 - Open PhpWikiAdministration/Chown for RichTablePlugin only. Result: I see
the correct owner.
Please review and let me know if there are any further related areas that I
can look into to help resolve my issues?
Regards,
Charles
lib/WikiDB/backend/PearDB.php: WikiDB_backend_PearDB ->
_extract_version_data() - line: 354
change 'pagename' to 'pagedata'
NOTE: I did not check whether this applied to ADODB or any of the
other formats
lib/WikiDB.php: WikiDB_cache -> get_versiondata
1 - I found that there was weirdness when trying to store an element with
key '0' into the cache structure, so change from ('0', '1') to ('1', '2').
This probably requires more testing on whether it has side effects on
ArchiveCleaner.php (see comments).
2 - Only update the _pagedata_cache from the _versiondata_cache if the
underlying data is actually queried.
Open questions
* Should $cache[$pagename][$version][$nc]['%pagedata'] be unset?
* Should $vdata['%pagedata'] be unset before return to the caller?
* Would this require a change to do an assignment without a reference into
_pagedata_cache[$pagename]?
Anyway, my replacement versions of the functions are below
function get_versiondata($pagename, $version, $need_content = false) {
// FIXME: Seriously ugly hackage
$readdata = false;
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.
//$need_content = true;
$nc = $need_content ? '2':'1';
$cache = &$this->_versiondata_cache;
if (!isset($cache[$pagename][$version][$nc])||
!(is_array ($cache[$pagename])) || !(is_array
($cache[$pagename][$version]))) {
$cache[$pagename][$version][$nc] =
$this->_backend->get_versiondata($pagename, $version,
$need_content);
$readdata = true;
// If we have retrieved all data, we may as well set the
cache for $need_content = false
if ($need_content){
$cache[$pagename][$version]['1'] =&
$cache[$pagename][$version]['2'];
}
}
$vdata = $cache[$pagename][$version][$nc];
} else {
$vdata = $this->_backend->get_versiondata($pagename, $version,
$need_content);
$readdata = true;
}
if ($readdata && $vdata && !empty($vdata['%pagedata'])) {
$this->_pagedata_cache[$pagename] =& $vdata['%pagedata'];
}
return $vdata;
}
function set_versiondata($pagename, $version, $data) {
//unset($this->_versiondata_cache[$pagename][$version]);
$new = $this->_backend->set_versiondata($pagename, $version, $data);
// Update the cache
$this->_versiondata_cache[$pagename][$version]['2'] = $data;
$this->_versiondata_cache[$pagename][$version]['1'] = $data;
// Is this necessary?
unset($this->_glv_cache[$pagename]);
}
function update_versiondata($pagename, $version, $data) {
$new = $this->_backend->update_versiondata($pagename, $version,
$data);
// Update the cache
$this->_versiondata_cache[$pagename][$version]['2'] = $data;
// FIXME: hack
$this->_versiondata_cache[$pagename][$version]['1'] = $data;
// Is this necessary?
unset($this->_glv_cache[$pagename]);
}
function delete_versiondata($pagename, $version) {
$new = $this->_backend->delete_versiondata($pagename, $version);
if (isset($this->_versiondata_cache[$pagename][$version]['2']))
unset ($this->_versiondata_cache[$pagename][$version]['2']);
if (isset($this->_versiondata_cache[$pagename][$version]['1']))
unset ($this->_versiondata_cache[$pagename][$version]['1']);
if (isset($this->_glv_cache[$pagename]))
unset ($this->_glv_cache[$pagename]);
}
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Phpwiki-talk mailing list
Phpwiki-talk@...
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk
|