BUGFIX: Don't rely on the current working directory for any file access; use BASE_PATH.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97728 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-01-28 05:10:32 +00:00
parent aa27047ed9
commit 9ac547d32d
8 changed files with 26 additions and 23 deletions

View File

@ -98,5 +98,5 @@ if(defined('SS_USE_BASIC_AUTH') && SS_USE_BASIC_AUTH) {
} }
if(defined('SS_ERROR_LOG')) { if(defined('SS_ERROR_LOG')) {
SS_Log::add_writer(new SS_LogFileWriter('../' . SS_ERROR_LOG), SS_Log::WARN, '<='); SS_Log::add_writer(new SS_LogFileWriter(BASE_PATH . '/' . SS_ERROR_LOG), SS_Log::WARN, '<=');
} }

View File

@ -155,6 +155,19 @@ increase_memory_limit_to('64M');
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// INCLUDES // INCLUDES
/**
* Add sapphire/parsers and sapphire/thirdparty include paths, as well as adding a fixed reference
* to BASEPATH/sapphrie in case we chdir()
*/
// Add after the "." path but before other paths (so that they take precedence over the PEAR
// include paths)
set_include_path(str_replace('.' . PATH_SEPARATOR, '.' . PATH_SEPARATOR
. BASE_PATH . '/sapphire' . PATH_SEPARATOR
. BASE_PATH . '/sapphire/parsers' . PATH_SEPARATOR
. BASE_PATH . '/sapphire/thirdparty' . PATH_SEPARATOR
, get_include_path()));
require_once("core/ManifestBuilder.php"); require_once("core/ManifestBuilder.php");
require_once("core/ClassInfo.php"); require_once("core/ClassInfo.php");
require_once('core/Object.php'); require_once('core/Object.php');
@ -162,17 +175,6 @@ require_once('core/control/Director.php');
require_once('filesystem/Filesystem.php'); require_once('filesystem/Filesystem.php');
require_once("core/Session.php"); require_once("core/Session.php");
/**
* Add sapphire/parsers and sapphire/thirdparty include paths
*/
// Add after the "." path but before other paths (so that they take precedence over the PEAR
// include paths)
set_include_path(str_replace('.' . PATH_SEPARATOR, '.' . PATH_SEPARATOR
. BASE_PATH . '/sapphire/parsers' . PATH_SEPARATOR
. BASE_PATH . '/sapphire/thirdparty' . PATH_SEPARATOR
, get_include_path()));
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// MANIFEST // MANIFEST

View File

@ -499,11 +499,11 @@ HTML
); );
foreach($installfiles as $installfile) { foreach($installfiles as $installfile) {
if(file_exists('../' . $installfile)) { if(file_exists(BASE_PATH . '/' . $installfile)) {
@unlink('../' . $installfile); @unlink(BASE_PATH . '/' . $installfile);
} }
if(file_exists('../' . $installfile)) { if(file_exists(BASE_PATH . '/' . $installfile)) {
$unsuccessful[] = $installfile; $unsuccessful[] = $installfile;
} }
} }

View File

@ -17,7 +17,7 @@ class SapphireInfo extends Controller {
} }
function Version() { function Version() {
$sapphireVersionFile = file_get_contents('../sapphire/silverstripe_version'); $sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
if(strstr($sapphireVersionFile, "/sapphire/trunk")) { if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
$sapphireVersion = "trunk"; $sapphireVersion = "trunk";

View File

@ -309,7 +309,7 @@ HTML;
$fixtureFile = $_GET['fixture']; $fixtureFile = $_GET['fixture'];
// Validate fixture file // Validate fixture file
$realFile = realpath('../' . $fixtureFile); $realFile = realpath(BASE_PATH.'/'.$fixtureFile);
$baseDir = realpath(Director::baseFolder()); $baseDir = realpath(Director::baseFolder());
if(!$realFile || !file_exists($realFile)) { if(!$realFile || !file_exists($realFile)) {
return "<p>Fixture file doesn't exist</p>"; return "<p>Fixture file doesn't exist</p>";

View File

@ -22,7 +22,8 @@ class TarballArchive extends Archive {
function listing() { function listing() {
// Call tar on the command line to get the info we need // Call tar on the command line to get the info we need
$command = "tar -tv{$this->compressionModifiers}f ../$this->filename"; $base = BASE_PATH;
$command = "tar -tv{$this->compressionModifiers}f $base/$this->filename";
$consoleList = `$command`; $consoleList = `$command`;
$listing = array(); $listing = array();

View File

@ -17,7 +17,7 @@ class PhpSyntaxTest extends SapphireTest {
$settingTests = array('short_open_tag=Off','short_open_tag=On -d asp_tags=On'); $settingTests = array('short_open_tag=Off','short_open_tag=On -d asp_tags=On');
$files = $this->getAllFiles('php'); $files = $this->getAllFiles('php');
$files[] = '../sapphire/dev/install/config-form.html'; $files[] = BASE_PATH.'/sapphire/dev/install/config-form.html';
foreach($files as $i => $file) { foreach($files as $i => $file) {
$CLI_file = escapeshellarg($file); $CLI_file = escapeshellarg($file);

View File

@ -103,14 +103,14 @@ class FileTest extends SapphireTest {
$fileIDs = $this->allFixtureIDs('Folder'); $fileIDs = $this->allFixtureIDs('Folder');
foreach($fileIDs as $fileID) { foreach($fileIDs as $fileID) {
$file = DataObject::get_by_id('Folder', $fileID); $file = DataObject::get_by_id('Folder', $fileID);
if(!file_exists("../$file->Filename")) mkdir("../$file->Filename"); if(!file_exists(BASE_PATH."/$file->Filename")) mkdir(BASE_PATH."/$file->Filename");
} }
/* Create a test files for each of the fixture references */ /* Create a test files for each of the fixture references */
$fileIDs = $this->allFixtureIDs('File'); $fileIDs = $this->allFixtureIDs('File');
foreach($fileIDs as $fileID) { foreach($fileIDs as $fileID) {
$file = DataObject::get_by_id('File', $fileID); $file = DataObject::get_by_id('File', $fileID);
$fh = fopen("../$file->Filename", "w"); $fh = fopen(BASE_PATH."/$file->Filename", "w");
fwrite($fh, str_repeat('x',1000000)); fwrite($fh, str_repeat('x',1000000));
fclose($fh); fclose($fh);
} }
@ -121,14 +121,14 @@ class FileTest extends SapphireTest {
$fileIDs = $this->allFixtureIDs('File'); $fileIDs = $this->allFixtureIDs('File');
foreach($fileIDs as $fileID) { foreach($fileIDs as $fileID) {
$file = DataObject::get_by_id('File', $fileID); $file = DataObject::get_by_id('File', $fileID);
if(file_exists("../$file->Filename")) unlink("../$file->Filename"); if(file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
} }
/* Remove the test folders that we've crated */ /* Remove the test folders that we've crated */
$fileIDs = $this->allFixtureIDs('Folder'); $fileIDs = $this->allFixtureIDs('Folder');
foreach($fileIDs as $fileID) { foreach($fileIDs as $fileID) {
$file = DataObject::get_by_id('Folder', $fileID); $file = DataObject::get_by_id('Folder', $fileID);
if(file_exists("../$file->Filename")) rmdir("../$file->Filename"); if(file_exists(BASE_PATH."/$file->Filename")) rmdir(BASE_PATH."/$file->Filename");
} }
parent::tearDown(); parent::tearDown();