From ccc8dd061cd5776943bd6d5cddaf286e3577b64f Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sun, 16 Mar 2014 17:14:43 +1300 Subject: [PATCH] If default path is not writable, fallback to tmp dir. --- code/TestSessionEnvironment.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/TestSessionEnvironment.php b/code/TestSessionEnvironment.php index 467f9a3..592b94a 100644 --- a/code/TestSessionEnvironment.php +++ b/code/TestSessionEnvironment.php @@ -67,10 +67,16 @@ class TestSessionEnvironment extends Object { */ public function getFilePath() { if($this->id) { - return Director::getAbsFile(sprintf($this->config()->test_state_id_file, $this->id)); + $path = Director::getAbsFile(sprintf($this->config()->test_state_id_file, $this->id)); } else { - return Director::getAbsFile($this->config()->test_state_file); + $path = Director::getAbsFile($this->config()->test_state_file); } + + if(!is_writable(dirname($path))) { + $path = str_replace(Director::baseFolder(), TEMP_FOLDER, $path); + } + + return $path; } /**