mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Include php version in default cache folder name
Update CoreTest.php
This commit is contained in:
parent
f8fe4a9096
commit
047fe3a410
@ -64,8 +64,9 @@ function getTempParentFolder($base = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// failing the above, try finding a namespaced silverstripe-cache dir in the system temp
|
// failing the above, try finding a namespaced silverstripe-cache dir in the system temp
|
||||||
$cacheFolder = DIRECTORY_SEPARATOR . 'silverstripe-cache' . str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
$tempPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR .
|
||||||
$tempPath = sys_get_temp_dir() . $cacheFolder;
|
'silverstripe-cache-php' . preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION) .
|
||||||
|
str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
||||||
if(!@file_exists($tempPath)) {
|
if(!@file_exists($tempPath)) {
|
||||||
$oldUMask = umask(0);
|
$oldUMask = umask(0);
|
||||||
$worked = @mkdir($tempPath, 0777);
|
$worked = @mkdir($tempPath, 0777);
|
||||||
|
@ -22,20 +22,22 @@ class CoreTest extends SapphireTest {
|
|||||||
$this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . DIRECTORY_SEPARATOR . $user);
|
$this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . DIRECTORY_SEPARATOR . $user);
|
||||||
} else {
|
} else {
|
||||||
$user = getTempFolderUsername();
|
$user = getTempFolderUsername();
|
||||||
|
$base = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'silverstripe-cache-php' .
|
||||||
|
preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION);
|
||||||
|
|
||||||
// A typical Windows location for where sites are stored on IIS
|
// A typical Windows location for where sites are stored on IIS
|
||||||
$this->assertEquals(sys_get_temp_dir() . DIRECTORY_SEPARATOR .
|
$this->assertEquals(
|
||||||
'silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
$base . 'C--inetpub-wwwroot-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
||||||
getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
|
getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
|
||||||
|
|
||||||
// A typical Mac OS X location for where sites are stored
|
// A typical Mac OS X location for where sites are stored
|
||||||
$this->assertEquals(sys_get_temp_dir() . DIRECTORY_SEPARATOR .
|
$this->assertEquals(
|
||||||
'silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
$base . '-Users-joebloggs-Sites-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
||||||
getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
|
getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
|
||||||
|
|
||||||
// A typical Linux location for where sites are stored
|
// A typical Linux location for where sites are stored
|
||||||
$this->assertEquals(sys_get_temp_dir() . DIRECTORY_SEPARATOR .
|
$this->assertEquals(
|
||||||
'silverstripe-cache-var-www-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
$base . '-var-www-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user,
|
||||||
getTempFolder('/var/www/silverstripe-test-project'));
|
getTempFolder('/var/www/silverstripe-test-project'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,12 +45,14 @@ class CoreTest extends SapphireTest {
|
|||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
$user = getTempFolderUsername();
|
$user = getTempFolderUsername();
|
||||||
|
$base = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'silverstripe-cache-php' .
|
||||||
|
preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION);
|
||||||
foreach(array(
|
foreach(array(
|
||||||
'silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project',
|
'C--inetpub-wwwroot-silverstripe-test-project',
|
||||||
'silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project',
|
'-Users-joebloggs-Sites-silverstripe-test-project',
|
||||||
'silverstripe-cache-var-www-silverstripe-test-project'
|
'-cache-var-www-silverstripe-test-project'
|
||||||
) as $dir) {
|
) as $dir) {
|
||||||
$path = sys_get_temp_dir().DIRECTORY_SEPARATOR.$dir;
|
$path = $base . $dir;
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
rmdir($path . DIRECTORY_SEPARATOR . $user);
|
rmdir($path . DIRECTORY_SEPARATOR . $user);
|
||||||
rmdir($path);
|
rmdir($path);
|
||||||
|
Loading…
Reference in New Issue
Block a user