clear_cache() problem/solution

From: Date: Sat, 21 Sep 2002 21:46:11 +0000
Subject: clear_cache() problem/solution
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6005@lists.php.net to get a copy of this message
Hello, two days ago I was about to post my problem here. In the end I didn't, but today I fixed it myself. Situation: I have some guestbook-page, which will get splitted into several pages if there are too many entries. So I use caching with the page number as an cache_id. If I add some entry I want to clear all cached pages of this guestbook-template. The expexted behaviour of clear_cache should be like this: clear_cache ('test.tpl', 'page 1'): clear only this page clear_cache ('test.tpl'): clear 'test.tpl' (without cache_id) _AND_ clear all 'test.tpl' with any cache_id. But the second point didn't happen. Can you follow me? Okay, I tried to figure out what smarty does and I think there is maybe a small bug in smarty 2.3.0: I changed the following lines and now it works: Smarty.class.php, line 1524 // original: if(isset($auto_source)) // BUT I want to check if there is any cache_id (here = $auto_id) if(isset($auto_id)) { Smarty.class.php, line 1535 //original: //elseif (substr($auto_base . DIR_SEP . $filename,0,strlen($tname)) == $tname) { // the file format is like this: cache_id^template_name // so I like to compare the last part of the path+filename, not the beginning // change 0, strlen(.. to 0-strlen(... // use $auto_source instead of $tname
                  } elseif (substr($auto_base . DIR_SEP . $filename,0-strlen($auto_source)) == $auto_source) {
                          $this->_unlink($auto_base . DIR_SEP . $filename, $exp_time);
I hope this helps anybody. Comments welcome! Cheers, Christian Schloh__________________________________________________
schöner browsen netzwerk_projekte          www.schoener-browsen.de


« previous php.smarty.general (#6005) next »