Jump to:

23482 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Error in RebuildStaticCacheTask.php ?!

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

Page: 1
Go to End
Author Topic: 571 Views
  • tekilla83
    Avatar
    Community Member
    20 Posts

    Error in RebuildStaticCacheTask.php ?! Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5507 Posts

    Re: Error in RebuildStaticCacheTask.php ?! Link to this post

    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

  • tekilla83
    Avatar
    Community Member
    20 Posts

    Re: Error in RebuildStaticCacheTask.php ?! Link to this post

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

    571 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.