diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 152753e8..1547350d 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -971,6 +971,7 @@ class LeftAndMain extends Controller { * @return int */ public function currentPageID() { + SS_Backtrace::backtrace(); if($this->request->getVar('ID')) { return $this->request->getVar('ID'); } elseif ($this->request->param('ID') && is_numeric($this->request->param('ID'))) { diff --git a/tasks/RebuildStaticCacheTask.php b/tasks/RebuildStaticCacheTask.php index 74550659..11018544 100644 --- a/tasks/RebuildStaticCacheTask.php +++ b/tasks/RebuildStaticCacheTask.php @@ -44,6 +44,11 @@ class RebuildStaticCacheTask extends Controller { echo "Rebuilding cache.\nNOTE: Please ensure that this page ends with 'Done!' - if not, then something may have gone wrong.\n\n"; $page = singleton('Page'); + $cacheBaseDir = $page->getDestDir(); + + if (file_exists($cacheBaseDir.'/lock') && !isset($_REQUEST['force'])) die("There already appears to be a publishing queue running. You can skip warning this by adding ?/&force to the URL."); + + touch($cacheBaseDir.'/lock'); foreach($urls as $i => $url) { if($url && !is_string($url)) { @@ -68,8 +73,6 @@ class RebuildStaticCacheTask extends Controller { if(!isset($_GET['urls']) && $start == 0 && file_exists("../cache")) { echo "Removing stale cache files... \n"; flush(); - $cacheBaseDir = $page->getDestDir(); - if (FilesystemPublisher::$domain_based_caching) { // Glob each dir, then glob each one of those foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) { @@ -89,6 +92,9 @@ class RebuildStaticCacheTask extends Controller { } echo "Rebuilding cache from " . sizeof($mappedUrls) . " urls...\n\n"; $page->extend('publishPages', $mappedUrls); + + if (file_exists($cacheBaseDir.'/lock')) unlink($cacheBaseDir.'/lock'); + echo "\n\n== Done! =="; }