Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Error in RebuildStaticCacheTask.php ?!


Reply


3 Posts   656 Views

Avatar
tekilla83

Community Member, 20 Posts

12 July 2011 at 1:59am

Edited: 12/07/2011 3:54am

In an older Version I found:

if($removeAll && file_exists("../cache")) {
echo "Removing old cache... \n";
flush();
Filesystem::removeFolder("../cache", true);
echo "done.\n\n";
}

in 2.4.5 Line 87 it says:

if($removeAll && !isset($_GET['urls']) && $start == 0 && file_exists("../cache")) {
         echo "Removing stale cache files... \n";
         flush();
         if (FilesystemPublisher::$domain_based_caching) {
            // Glob each dir, then glob each one of those
            foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
               foreach(glob($cacheDir.'/*') as $cacheFile) {
                  $searchCacheFile = trim(str_replace($cacheBaseDir, '', $cacheFile), '\/');
                  if (!in_array($searchCacheFile, $mappedUrls)) {
                     echo " * Deleting $cacheFile\n";
                     @unlink($cacheFile);
                  }
               }
            }
         } else {
            
         }

         
         echo "done.\n\n";
      }

Why is the else code empty?
FilesystemPublisher::$domain_based_caching is false for default. Shouldn't there be somethink like this:

Filesystem::removeFolder("../cache", true);

Offtopic: Where to report bugs? I think 'General Questions' is not the correkt place?

Edit: I set:

FilesystemPublisher::$domain_based_caching = true;


In my config.php and changed Link() to AbsoluteLink() in Page->subPagesToCache():

function subPagesToCache($translate='all') {
      $urls = array();
      // add current page
      if($this->nocache!=1){
         $urls[] = $this->AbsoluteLink();
         // add translations
         if($translate=='all'){
            $translations = Translatable::getTranslations();
            if(is_object($translations)){
               foreach($translations as $translation){
                  $urls[] = $translation->AbsoluteLink();
               }
            }
         }
         // cache the RSS feed if comments are enabled
         if ($this->ProvideComments) {
            $urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID;
         }
      }
      return $urls;

It doesn't deleting anything when I make a dev/buildcache

Avatar
Willr

Forum Moderator, 5513 Posts

12 July 2011 at 6:42pm

Offtopic: Where to report bugs? I think 'General Questions' is not the correkt place?

Bugs should go to open.silverstripe.org. If you have patches or code which you want to submit to the core it can either go to that open.silverstripe.org site or our new location on github.com/silverstripe/sapphire as a pull request.

http://doc.silverstripe.org/sapphire/en/misc/contributing

Avatar
tekilla83

Community Member, 20 Posts

13 July 2011 at 1:44am

Thanks Willr I've made a new Ticket: http://open.silverstripe.org/ticket/6679