From: Charles C. <ch...@ru...> - 2005-01-16 17:43:51
|
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]); } |