rename TEMP_FOLDER to TEMP_PATH

This commit is contained in:
Christopher Joe 2017-10-09 12:41:34 +13:00
parent 313f8c7ac3
commit 3560a0418d
16 changed files with 37 additions and 25 deletions

View File

@ -6,7 +6,7 @@ SilverStripe\Core\Injector\Injector:
class: 'SilverStripe\Core\Cache\DefaultCacheFactory'
constructor:
args:
directory: '`TEMP_FOLDER`'
directory: '`TEMP_PATH`'
version: null
logger: '%$Psr\Log\LoggerInterface'
Psr\SimpleCache\CacheInterface.cacheblock:

View File

@ -38,7 +38,7 @@ SilverStripe\Core\Injector\Injector:
constructor:
0: 'en'
1: null
2: '`TEMP_FOLDER`'
2: '`TEMP_PATH`'
properties:
ConfigCacheFactory: '%$Symfony\Component\Config\ConfigCacheFactoryInterface'
calls:

View File

@ -84,7 +84,7 @@ tasks silently in the background.
* Tries to locate an `.env`
[configuration file](/getting_started/environment_management) in the webroot.
* Sets constants based on the filesystem structure (e.g. `BASE_URL`, `BASE_PATH` and `TEMP_FOLDER`)
* Sets constants based on the filesystem structure (e.g. `BASE_URL`, `BASE_PATH` and `TEMP_PATH`)
All requests go through `main.php`, which sets up the core [Kernel](api:SilverStripe\Core\Kernel) and [HTTPApplication](api:SilverStripe\Control\HTTPApplication)
objects. See [/developer_guides/execution_pipeline/app_object_and_kernel] for details on this.

View File

@ -65,6 +65,7 @@ guide developers in preparing existing 3.x code for compatibility with 4.0
* Dependencies can managed via [recipe-plugin](https://github.com/silverstripe/recipe-plugin). See [recipe-core](https://github.com/silverstripe/recipe-core) and [recipe-cms](https://github.com/silverstripe/recipe-cms) as examples.
* Authentication has been upgraded to a modular approach using re-usable interfaces and easier to hook in to LoginHandlers.
* Core modules are installed in the `vendor/` folder by default (other modules can opt-in, see [guide](/developer_guides/extending/how_tos/publish_a_module))
* Renamed constant for temp folder from `TEMP_FOLDER` to `TEMP_PATH` for naming consistency with other path variables and constants
## <a name="upgrading"></a>Upgrading

View File

@ -57,7 +57,7 @@ class ParameterConfirmationToken
protected function pathForToken($token)
{
return TEMP_FOLDER.'/token_'.preg_replace('/[^a-z0-9]+/', '', $token);
return TEMP_PATH . DIRECTORY_SEPARATOR . 'token_'.preg_replace('/[^a-z0-9]+/', '', $token);
}
/**

View File

@ -169,7 +169,7 @@ class CsvBulkLoader extends BulkLoader
*/
protected function getNewSplitFileName()
{
return TEMP_FOLDER . DIRECTORY_SEPARATOR . uniqid(str_replace('\\', '_', static::class), true) . '.csv';
return TEMP_PATH . DIRECTORY_SEPARATOR . uniqid(str_replace('\\', '_', static::class), true) . '.csv';
}
/**

View File

@ -196,8 +196,9 @@ class DatabaseAdmin extends Controller
*/
public static function lastBuilt()
{
$file = TEMP_FOLDER
. '/database-last-generated-'
$file = TEMP_PATH
. DIRECTORY_SEPARATOR
. 'database-last-generated-'
. str_replace(array('\\','/',':'), '.', Director::baseFolder());
if (file_exists($file)) {
@ -371,8 +372,9 @@ class DatabaseAdmin extends Controller
}
}
touch(TEMP_FOLDER
. '/database-last-generated-'
touch(TEMP_PATH
. DIRECTORY_SEPARATOR
. 'database-last-generated-'
. str_replace(array('\\', '/', ':'), '.', Director::baseFolder()));
if (isset($_REQUEST['from_installer'])) {

View File

@ -500,10 +500,10 @@ class SSViewer implements Flushable
public static function flush_template_cache($force = false)
{
if (!self::$template_cache_flushed || $force) {
$dir = dir(TEMP_FOLDER);
$dir = dir(TEMP_PATH);
while (false !== ($file = $dir->read())) {
if (strstr($file, '.cache')) {
unlink(TEMP_FOLDER . '/' . $file);
unlink(TEMP_PATH . DIRECTORY_SEPARATOR . $file);
}
}
self::$template_cache_flushed = true;
@ -626,7 +626,7 @@ class SSViewer implements Flushable
$template = $this->chosen;
$cacheFile = TEMP_FOLDER . "/.cache"
$cacheFile = TEMP_PATH . DIRECTORY_SEPARATOR . '.cache'
. str_replace(['\\','/',':'], '.', Director::makeRelative(realpath($template)));
$lastEdited = filemtime($template);

View File

@ -50,7 +50,7 @@ class SSViewer_FromString extends SSViewer
public function process($item, $arguments = null, $scope = null)
{
$hash = sha1($this->content);
$cacheFile = TEMP_FOLDER . "/.cache.$hash";
$cacheFile = TEMP_PATH . DIRECTORY_SEPARATOR . ".cache.$hash";
if (!file_exists($cacheFile) || isset($_GET['flush'])) {
$content = $this->parseTemplateContent($this->content, "string sha1=$hash");

View File

@ -63,7 +63,7 @@ class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serial
*/
protected static function canary()
{
return TEMP_FOLDER . '/catalog.i18n_canary';
return TEMP_PATH . DIRECTORY_SEPARATOR . 'catalog.i18n_canary';
}
/**

View File

@ -15,7 +15,7 @@ use SilverStripe\Core\TempFolder;
* - BASE_URL: Full URL to the webroot, e.g. "http://my-host.com/my-webroot" (no trailing slash).
* - BASE_PATH: Absolute path to the webroot, e.g. "/var/www/my-webroot" (no trailing slash).
* See Director::baseFolder(). Can be overwritten by Config::modify()->set(Director::class, 'alternate_base_folder', ).
* - TEMP_FOLDER: Absolute path to temporary folder, used for manifest and template caches. Example: "/var/tmp"
* - TEMP_PATH: Absolute path to temporary folder, used for manifest and template caches. Example: "/var/tmp"
* See getTempFolder(). No trailing slash.
* - ASSETS_DIR: Dir for assets folder. e.g. "assets"
* - ASSETS_PATH: Full path to assets folder. e.g. "/var/www/my-webroot/assets"
@ -140,6 +140,15 @@ if (defined('CUSTOM_INCLUDE_PATH')) {
}
// Define the temporary folder if it wasn't defined yet
if (!defined('TEMP_FOLDER')) {
define('TEMP_FOLDER', TempFolder::getTempFolder(BASE_PATH));
if (!defined('TEMP_PATH')) {
if (defined('TEMP_FOLDER')) {
define('TEMP_PATH', TEMP_FOLDER);
} else {
define('TEMP_PATH', TempFolder::getTempFolder(BASE_PATH));
}
}
// Define the temporary folder for backwards compatibility
if (!defined('TEMP_FOLDER')) {
define('TEMP_FOLDER', TEMP_PATH);
}

View File

@ -54,7 +54,7 @@ class DirectorTest extends SapphireTest
public function testFileExists()
{
$tempFileName = 'DirectorTest_testFileExists.tmp';
$tempFilePath = TEMP_FOLDER . '/' . $tempFileName;
$tempFilePath = TEMP_PATH . DIRECTORY_SEPARATOR . $tempFileName;
// create temp file
file_put_contents($tempFilePath, '');

View File

@ -230,7 +230,7 @@ class InjectorTest extends SapphireTest
'properties' => array(
'filters' => array(
'`BASE_PATH`',
'`TEMP_FOLDER`',
'`TEMP_PATH`',
'`NOT_DEFINED`',
'THIRDPARTY_DIR' // Not back-tick escaped
)
@ -243,7 +243,7 @@ class InjectorTest extends SapphireTest
$this->assertEquals(
[
BASE_PATH,
TEMP_FOLDER,
TEMP_PATH,
null,
'THIRDPARTY_DIR',
],

View File

@ -79,7 +79,7 @@ require_once '$classpath';
$src .= "->execute();";
// Now stick it in a temporary file & run it
$codepath = TEMP_FOLDER . '/ErrorControlChainTest_' . sha1($src) . '.php';
$codepath = TEMP_PATH . DIRECTORY_SEPARATOR . 'ErrorControlChainTest_' . sha1($src) . '.php';
if ($includeStderr) {
$null = '&1';

View File

@ -1689,7 +1689,7 @@ after'
// as protocol-less absolute urls
$base = Convert::raw2att('/file.com?foo"onclick="alert(\'xss\')""');
$tmplFile = TEMP_FOLDER . '/SSViewerTest_testRewriteHashlinks_' . sha1(rand()) . '.ss';
$tmplFile = TEMP_PATH . DIRECTORY_SEPARATOR . 'SSViewerTest_testRewriteHashlinks_' . sha1(rand()) . '.ss';
// Note: SSViewer_FromString doesn't rewrite hash links.
file_put_contents(
@ -1746,7 +1746,7 @@ after'
{
SSViewer::setRewriteHashLinksDefault('php');
$tmplFile = TEMP_FOLDER . '/SSViewerTest_testRewriteHashlinksInPhpMode_' . sha1(rand()) . '.ss';
$tmplFile = TEMP_PATH . DIRECTORY_SEPARATOR . 'SSViewerTest_testRewriteHashlinksInPhpMode_' . sha1(rand()) . '.ss';
// Note: SSViewer_FromString doesn't rewrite hash links.
file_put_contents(
@ -2060,7 +2060,7 @@ EOC;
public function testFromStringCaching()
{
$content = 'Test content';
$cacheFile = TEMP_FOLDER . '/.cache.' . sha1($content);
$cacheFile = TEMP_PATH . DIRECTORY_SEPARATOR . '.cache.' . sha1($content);
if (file_exists($cacheFile)) {
unlink($cacheFile);
}

View File

@ -25,7 +25,7 @@ class i18nTextCollectorTest extends SapphireTest
parent::setUp();
$this->setupManifest();
$this->alternateBaseSavePath = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'i18nTextCollectorTest_webroot';
$this->alternateBaseSavePath = TEMP_PATH . DIRECTORY_SEPARATOR . 'i18nTextCollectorTest_webroot';
Filesystem::makeFolder($this->alternateBaseSavePath);
}