From d6117630bdc3be78f6426cf672cda6e68762a4ba Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 2 Oct 2018 12:55:49 +1300 Subject: [PATCH] FIX: Stricter regex syntax for PHP7.3 support. --- core/TempPath.php | 2 +- tests/core/CoreTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/TempPath.php b/core/TempPath.php index 4f3a94c85..0bc6645e5 100644 --- a/core/TempPath.php +++ b/core/TempPath.php @@ -12,7 +12,7 @@ function getTempFolder($base = null) { $parent = getTempParentFolder($base); // The actual temp folder is a subfolder of getTempParentFolder(), named by username and suffixed with currently used php-version - $phpversion = '-php' . preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION); + $phpversion = '-php' . preg_replace('/[^\w\-\.+]+/', '-', PHP_VERSION); $subfolder = $parent . DIRECTORY_SEPARATOR . getTempFolderUsername() . $phpversion; if(!@file_exists($subfolder)) { diff --git a/tests/core/CoreTest.php b/tests/core/CoreTest.php index 5b4cc7510..06c716255 100644 --- a/tests/core/CoreTest.php +++ b/tests/core/CoreTest.php @@ -17,7 +17,7 @@ class CoreTest extends SapphireTest { public function testGetTempPathInProject() { $user = getTempFolderUsername(); - $phpversion = '-php' . preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION); + $phpversion = '-php' . preg_replace('/[^\w\-\.+]+/', '-', PHP_VERSION); if(file_exists($this->tempPath)) { $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . DIRECTORY_SEPARATOR . $user . $phpversion); } else { @@ -43,9 +43,9 @@ class CoreTest extends SapphireTest { public function tearDown() { parent::tearDown(); $user = getTempFolderUsername(); - $phpversion = '-php' . preg_replace('/[^\w-\.+]+/', '-', PHP_VERSION); + $phpversion = '-php' . preg_replace('/[^\w\-\.+]+/', '-', PHP_VERSION); $base = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'silverstripe-cache' . $phpversion; - + foreach(array( 'C--inetpub-wwwroot-silverstripe-test-project', '-Users-joebloggs-Sites-silverstripe-test-project',