From 29292b865d9e50d745d158396effd4df9ef6a95b Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 13 Apr 2010 22:24:12 +0000 Subject: [PATCH] BUGFIX: Don't rely on the current directory for any logic. (from r97727) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102738 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 4 ++-- code/staticpublisher/FilesystemPublisher.php | 12 ++++++------ tasks/RebuildStaticCacheTask.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index c4754186..fd8fe597 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -1024,8 +1024,8 @@ class LeftAndMain extends Controller { * @return string */ public function CMSVersion() { - $sapphireVersionFile = file_get_contents('../sapphire/silverstripe_version'); - $cmsVersionFile = file_get_contents('../cms/silverstripe_version'); + $sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version'); + $cmsVersionFile = file_get_contents(BASE_PATH . '/cms/silverstripe_version'); if(strstr($sapphireVersionFile, "/sapphire/trunk")) { $sapphireVersion = "trunk"; diff --git a/code/staticpublisher/FilesystemPublisher.php b/code/staticpublisher/FilesystemPublisher.php index fe8c7f5f..346b734b 100644 --- a/code/staticpublisher/FilesystemPublisher.php +++ b/code/staticpublisher/FilesystemPublisher.php @@ -183,7 +183,7 @@ class FilesystemPublisher extends StaticPublisher { if(self::$static_base_url) Director::setBaseURL($currentBaseURL); if($this->fileExtension == 'php') SSViewer::setOption('rewriteHashlinks', true); - $base = "../$this->destFolder"; + $base = BASE_PATH . "/$this->destFolder"; foreach($files as $file) { Filesystem::makeFolder("$base/$file[Folder]"); @@ -201,7 +201,7 @@ class FilesystemPublisher extends StaticPublisher { * Generate the templated content for a PHP script that can serve up the given piece of content with the given age and expiry */ protected function generatePHPCacheFile($content, $age, $lastModified) { - $template = file_get_contents('../cms/code/staticpublisher/CachedPHPPage.tmpl'); + $template = file_get_contents(BASE_PATH . '/cms/code/staticpublisher/CachedPHPPage.tmpl'); return str_replace( array('**MAX_AGE**', '**LAST_MODIFIED**', '**CONTENT**'), array((int)$age, $lastModified, $content), @@ -211,7 +211,7 @@ class FilesystemPublisher extends StaticPublisher { * Generate the templated content for a PHP script that can serve up a 301 redirect to the given destionation */ protected function generatePHPCacheRedirection($destination) { - $template = file_get_contents('../cms/code/staticpublisher/CachedPHPRedirection.tmpl'); + $template = file_get_contents(BASE_PATH . '/cms/code/staticpublisher/CachedPHPRedirection.tmpl'); return str_replace( array('**DESTINATION**'), array($destination), @@ -219,7 +219,7 @@ class FilesystemPublisher extends StaticPublisher { } public function getDestDir() { - return '../'.$this->destFolder; + return BASE_PATH . '/' . $this->destFolder; } /** @@ -227,7 +227,7 @@ class FilesystemPublisher extends StaticPublisher { * Only returns cache files that will actually map to a URL, based on urlsToPaths. */ public function getExistingStaticCacheFiles() { - $cacheDir = '../'.$this->destFolder; + $cacheDir = BASE_PATH . '/' . $this->destFolder; $urlMapper = array_flip($this->urlsToPaths($this->owner->allPagesToCache())); @@ -236,7 +236,7 @@ class FilesystemPublisher extends StaticPublisher { // Glob each dir, then glob each one of those foreach(glob("$cacheDir/*", GLOB_ONLYDIR) as $cacheDir) { foreach(glob($cacheDir.'/*') as $cacheFile) { - $mapKey = str_replace("../cache/","",$cacheFile); + $mapKey = str_replace(BASE_PATH . "/cache/","",$cacheFile); if(isset($urlMapper[$mapKey])) { $url = $urlMapper[$mapKey]; $output[$url] = $cacheFile; diff --git a/tasks/RebuildStaticCacheTask.php b/tasks/RebuildStaticCacheTask.php index aacdc185..74550659 100644 --- a/tasks/RebuildStaticCacheTask.php +++ b/tasks/RebuildStaticCacheTask.php @@ -72,7 +72,7 @@ class RebuildStaticCacheTask extends Controller { if (FilesystemPublisher::$domain_based_caching) { // Glob each dir, then glob each one of those - foreach(glob('../cache/*', GLOB_ONLYDIR) as $cacheDir) { + 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)) {