From: Charles C. <ch...@ru...> - 2005-01-31 15:04:00
Attachments:
WikiDB.php.patch
|
A patch to lib/WikiDB.php follows. This is part 2 of my previous set of fixes to the caching logic. While debugging why caching was not working for me, I found that get_versiondata() was behaving weirdly when the parameter $need_content was false. It appears that php 4.3.10 on windows gets confused when an array element is created with an index of '0'. This patch changes the array index to use '2' and '1' instead of '1' and '0'. Note that this patch also contains the previous patch in the series - I do not know enough about CVS and Eclipse to get just the incremental changes from my previous patch. Regards, Charles 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:56:33 -0000 @@ -2045,28 +2045,31 @@ } 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. //$need_content = true; - $nc = $need_content ? '1':'0'; + $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); + $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']; + $cache[$pagename][$version]['1'] =& $cache[$pagename][$version]['2']; } } $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; @@ -2077,8 +2080,8 @@ $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; - $this->_versiondata_cache[$pagename][$version]['0'] = $data; // Is this necessary? unset($this->_glv_cache[$pagename]); } @@ -2086,19 +2089,19 @@ function update_versiondata($pagename, $version, $data) { $new = $this->_backend->update_versiondata($pagename, $version, $data); // Update the cache - $this->_versiondata_cache[$pagename][$version]['1'] = $data; + $this->_versiondata_cache[$pagename][$version]['2'] = $data; // FIXME: hack - $this->_versiondata_cache[$pagename][$version]['0'] = $data; + $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->_versiondata_cache[$pagename][$version]['0'])) - unset ($this->_versiondata_cache[$pagename][$version]['0']); if (isset($this->_glv_cache[$pagename])) unset ($this->_glv_cache[$pagename]); } |
From: Charles C. <ch...@ru...> - 2005-01-31 15:05:13
Attachments:
WikiDB.php.patch
|
A patch to lib/WikiDB.php follows. This is part 2 of my previous set of fixes to the caching logic. While debugging why caching was not working for me, I found that get_versiondata() was behaving weirdly when the parameter $need_content was false. It appears that php 4.3.10 on windows gets confused when an array element is created with an index of '0'. This patch changes the array index to use '2' and '1' instead of '1' and '0'. Note that this patch also contains the previous patch in the series - I do not know enough about CVS and Eclipse to get just the incremental changes from my previous patch. Regards, Charles 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:56:33 -0000 @@ -2045,28 +2045,31 @@ } 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. //$need_content = true; - $nc = $need_content ? '1':'0'; + $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); + $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']; + $cache[$pagename][$version]['1'] =& + $cache[$pagename][$version]['2']; } } $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; @@ -2077,8 +2080,8 @@ $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; - $this->_versiondata_cache[$pagename][$version]['0'] = $data; // Is this necessary? unset($this->_glv_cache[$pagename]); } @@ -2086,19 +2089,19 @@ function update_versiondata($pagename, $version, $data) { $new = $this->_backend->update_versiondata($pagename, $version, $data); // Update the cache - $this->_versiondata_cache[$pagename][$version]['1'] = $data; + $this->_versiondata_cache[$pagename][$version]['2'] = $data; // FIXME: hack - $this->_versiondata_cache[$pagename][$version]['0'] = $data; + $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->_versiondata_cache[$pagename][$version]['0'])) - unset ($this->_versiondata_cache[$pagename][$version]['0']); if (isset($this->_glv_cache[$pagename])) unset ($this->_glv_cache[$pagename]); } |
From: Reini U. <ru...@x-...> - 2005-01-31 21:09:43
|
Charles Corrigan schrieb: > A patch to lib/WikiDB.php follows. This is part 2 of my previous set of fixes to the caching logic. > > While debugging why caching was not working for me, I found that get_versiondata() was behaving weirdly when the parameter > $need_content was false. It appears that php 4.3.10 on windows gets confused when an array element is created with an index of '0'. Please try to update your zend optimizer first. https://www.zend.com/store/products/zend-optimizer.php I had the same problem. > This patch changes the array index to use '2' and '1' instead of '1' and '0'. Note that this patch also contains the previous patch > in the series - I do not know enough about CVS and Eclipse to get just the incremental changes from my previous patch. -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ |
From: Charles C. <ch...@ru...> - 2005-02-01 00:07:54
|
> Charles Corrigan schrieb: > > A patch to lib/WikiDB.php follows. This is part 2 of my previous set of fixes to the > > caching logic. > > > > While debugging why caching was not working for me, I found that get_versiondata() > > was behaving weirdly when the parameter $need_content was false. It appears that > > php 4.3.10 on windows gets confused when an array element is created with an index > > of '0'. > Please try to update your zend optimizer first. > https://www.zend.com/store/products/zend-optimizer.php > I had the same problem. I have never downloaded or used the zend optimizer on my windows machine, this is a stock php 4.3.10 on windows. Therefore I suggest that the change is made as it will affect others that know nothing of the zend optimizer. The patch is merely a change to otherwise unused constants, not a change to logic. Regards, Charles |
From: Reini U. <ru...@x-...> - 2005-02-01 09:03:18
|
Charles Corrigan schrieb: >>Charles Corrigan schrieb: >>>A patch to lib/WikiDB.php follows. This is part 2 of my previous set of fixes to the >>>caching logic. >>> >>>While debugging why caching was not working for me, I found that get_versiondata() >>>was behaving weirdly when the parameter $need_content was false. It appears that >>>php 4.3.10 on windows gets confused when an array element is created with an index >>>of '0'. > >>Please try to update your zend optimizer first. >> https://www.zend.com/store/products/zend-optimizer.php >>I had the same problem. > > I have never downloaded or used the zend optimizer on my windows machine, this is a stock php 4.3.10 on windows. Therefore I > suggest that the change is made as it will affect others that know nothing of the zend optimizer. The patch is merely a change to > otherwise unused constants, not a change to logic. Ok, I will apply this patch, because it's simple and the index ['0'], has some ill magic. (empty, isset, ...) But the point is still: If your php is broken you have to fix the real problem, because this special case in WikiDB_Cache will not be the only problem then. -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ |