[FEATURE] Use dynamic path for typo3temp/var/ 13/56413/9
authorBenni Mack <benni@typo3.org>
Wed, 21 Mar 2018 19:03:38 +0000 (20:03 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 29 Mar 2018 09:23:39 +0000 (11:23 +0200)
All TYPO3 Core areas where typo3temp/var/ was directly used,
the new Environment::getVarPath() API is now used.

When running via composer or setting the environment
variable "TYPO3_PATH_APP", the folder is $projectRootPath . /var
otherwise "typo3temp/var/" as before.

Additional changes to the default naming scheme
- Cache folders are now named lower-case (Cache/Code becomes
cache/code).
- Install tool session files are stored within "var/session" instead of
"var/InstallToolSessions".
- Extension Manager files are now within "var/extensionmanager"
in a lower-cased variant
- log files are now placed into "var/log" instead of "var/logs"
- lock files are now placed into "var/lock" instead of "var/locks"

Resolves: #84545
Releases: master
Change-Id: Ifa57413cd212243387532ffb3435cfca361a582b
Reviewed-on: https://review.typo3.org/56413
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
33 files changed:
typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php
typo3/sysext/core/Classes/Charset/CharsetConverter.php
typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
typo3/sysext/core/Classes/Locking/FileLockStrategy.php
typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php
typo3/sysext/core/Classes/Locking/SimpleLockStrategy.php
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Classes/Resource/OnlineMedia/Helpers/AbstractOnlineMediaHelper.php
typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Documentation/Changelog/9.0/Breaking-57594-OptimizeReflectionServiceCacheHandling.rst
typo3/sysext/core/Documentation/Changelog/9.0/Feature-57594-OptimizeReflectionServiceCacheHandling.rst
typo3/sysext/core/Documentation/Changelog/master/Feature-84545-AllowTemporaryFilesToBeStoredOutsideTheDocumentRoot.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/FileBackendTest.php
typo3/sysext/core/Tests/Unit/Locking/FileLockStrategyTest.php
typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php
typo3/sysext/core/Tests/Unit/Mail/TransportFactoryTest.php
typo3/sysext/documentation/Classes/Service/DocumentationService.php
typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php
typo3/sysext/extensionmanager/Classes/Utility/Repository/Helper.php
typo3/sysext/extensionmanager/Classes/Utility/UpdateScriptUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php
typo3/sysext/impexp/Classes/ImportExport.php
typo3/sysext/install/Classes/Controller/MaintenanceController.php
typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
typo3/sysext/install/Classes/Report/InstallStatusReport.php
typo3/sysext/install/Classes/Service/ClearCacheService.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php
typo3/sysext/install/Classes/Service/LanguagePackService.php
typo3/sysext/install/Classes/Service/SessionService.php
typo3/sysext/rsaauth/Classes/Backend/CommandLineBackend.php
typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php

index f300592..91acb1f 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
@@ -76,13 +77,13 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
         parent::setCache($cache);
         if (empty($this->temporaryCacheDirectory)) {
             // If no cache directory was given with cacheDirectory
-            // configuration option, set it to a path below typo3temp/var/
-            $temporaryCacheDirectory = PATH_site . 'typo3temp/var/';
+            // configuration option, set it to a path below var/ folder
+            $temporaryCacheDirectory = Environment::getVarPath() . '/';
         } else {
             $temporaryCacheDirectory = $this->temporaryCacheDirectory;
         }
-        $codeOrData = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? 'Code' : 'Data';
-        $finalCacheDirectory = $temporaryCacheDirectory . 'Cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
+        $codeOrData = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? 'code' : 'data';
+        $finalCacheDirectory = $temporaryCacheDirectory . 'cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
         if (!is_dir($finalCacheDirectory)) {
             $this->createFinalCacheDirectory($finalCacheDirectory);
         }
index 46bd9c8..9249144 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Charset;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -643,7 +644,7 @@ class CharsetConverter implements SingletonInterface
             if ($charset && GeneralUtility::validPathStr($charsetConvTableFile) && @is_file($charsetConvTableFile)) {
                 // Cache file for charsets:
                 // Caching brought parsing time for gb2312 down from 2400 ms to 150 ms. For other charsets we are talking 11 ms down to zero.
-                $cacheFile = GeneralUtility::getFileAbsFileName('typo3temp/var/charset/charset_' . $charset . '.tbl');
+                $cacheFile = Environment::getVarPath() . '/charset/charset_' . $charset . '.tbl';
                 if ($cacheFile && @is_file($cacheFile)) {
                     $this->parsedCharsets[$charset] = unserialize(file_get_contents($cacheFile));
                 } else {
@@ -702,8 +703,8 @@ class CharsetConverter implements SingletonInterface
     public function initUnicodeData($mode = null)
     {
         // Cache files
-        $cacheFileCase = GeneralUtility::getFileAbsFileName('typo3temp/var/charset/cscase_utf-8.tbl');
-        $cacheFileASCII = GeneralUtility::getFileAbsFileName('typo3temp/var/charset/csascii_utf-8.tbl');
+        $cacheFileCase = Environment::getVarPath() . '/charset/cscase_utf-8.tbl';
+        $cacheFileASCII = Environment::getVarPath() . '/charset/csascii_utf-8.tbl';
         // Only process if the tables are not yet loaded
         switch ($mode) {
             case 'case':
@@ -943,7 +944,7 @@ class CharsetConverter implements SingletonInterface
             return 1;
         }
         // Use cached version if possible
-        $cacheFile = GeneralUtility::getFileAbsFileName('typo3temp/var/charset/cscase_' . $charset . '.tbl');
+        $cacheFile = Environment::getVarPath() . '/charset/cscase_' . $charset . '.tbl';
         if ($cacheFile && @is_file($cacheFile)) {
             $this->caseFolding[$charset] = unserialize(file_get_contents($cacheFile));
             return 2;
@@ -1005,7 +1006,7 @@ class CharsetConverter implements SingletonInterface
             return 1;
         }
         // Use cached version if possible
-        $cacheFile = GeneralUtility::getFileAbsFileName('typo3temp/var/charset/csascii_' . $charset . '.tbl');
+        $cacheFile = Environment::getVarPath() . '/charset/csascii_' . $charset . '.tbl';
         if ($cacheFile && @is_file($cacheFile)) {
             $this->toASCII[$charset] = unserialize(file_get_contents($cacheFile));
             return 2;
index ad9487d..a28e967 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Imaging;
 
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -1922,8 +1923,8 @@ class GraphicalFunctions
      */
     public function randomName()
     {
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/transient/');
-        return PATH_site . 'typo3temp/var/transient/' . md5(uniqid('', true));
+        GeneralUtility::mkdir_deep(Environment::getVarPath() . '/transient/');
+        return Environment::getVarPath() . '/transient/' . md5(uniqid('', true));
     }
 
     /**
index 0f2360f..6aef9a8 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Locking;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireException;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException;
 use TYPO3\CMS\Core\Locking\Exception\LockCreateException;
@@ -24,7 +25,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class FileLockStrategy implements LockingStrategyInterface
 {
-    const FILE_LOCK_FOLDER = 'typo3temp/var/locks/';
+    const FILE_LOCK_FOLDER = 'lock/';
 
     /**
      * @var resource File pointer if using flock method
@@ -50,9 +51,9 @@ class FileLockStrategy implements LockingStrategyInterface
         /*
          * Tests if the directory for simple locks is available.
          * If not, the directory will be created. The lock path is usually
-         * below typo3temp/var, typo3temp/var itself should exist already
+         * below typo3temp/var, typo3temp/var itself should exist already (or root-path/var/ respectively)
          */
-        $path = PATH_site . self::FILE_LOCK_FOLDER;
+        $path = Environment::getVarPath() . '/' . self::FILE_LOCK_FOLDER;
         if (!is_dir($path)) {
             // Not using mkdir_deep on purpose here, if typo3temp itself
             // does not exist, this issue should be solved on a different
index db1c334..016fd5c 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Locking;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireException;
 use TYPO3\CMS\Core\Locking\Exception\LockCreateException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -23,7 +24,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class SemaphoreLockStrategy implements LockingStrategyInterface
 {
-    const FILE_LOCK_FOLDER = 'typo3temp/var/locks/';
+    const FILE_LOCK_FOLDER = 'lock/';
 
     /**
      * @var mixed Identifier used for this lock
@@ -51,7 +52,7 @@ class SemaphoreLockStrategy implements LockingStrategyInterface
      */
     public function __construct($subject)
     {
-        $path = PATH_site . self::FILE_LOCK_FOLDER;
+        $path = Environment::getVarPath() . '/' . self::FILE_LOCK_FOLDER;
         if (!is_dir($path)) {
             // Not using mkdir_deep on purpose here, if typo3temp/var itself
             // does not exist, this issue should be solved on a different
index 2ebc43a..bd792c2 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Locking;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException;
 use TYPO3\CMS\Core\Locking\Exception\LockCreateException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -23,7 +24,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class SimpleLockStrategy implements LockingStrategyInterface
 {
-    const FILE_LOCK_FOLDER = 'typo3temp/var/locks/';
+    const FILE_LOCK_FOLDER = 'lock/';
 
     /**
      * @var string File path used for this lock
@@ -53,8 +54,8 @@ class SimpleLockStrategy implements LockingStrategyInterface
     {
         // Tests if the directory for simple locks is available.
         // If not, the directory will be created. The lock path is usually
-        // below typo3temp/var, typo3temp/var itself should exist already
-        $path = PATH_site . self::FILE_LOCK_FOLDER;
+        // below typo3temp/var, typo3temp/var itself should exist already (or getProjectPath . /var/ respectively)
+        $path = Environment::getVarPath() . '/' . self::FILE_LOCK_FOLDER;
         if (!is_dir($path)) {
             // Not using mkdir_deep on purpose here, if typo3temp/var itself
             // does not exist, this issue should be solved on a different
@@ -102,7 +103,7 @@ class SimpleLockStrategy implements LockingStrategyInterface
         $success = true;
         if (
             GeneralUtility::isAllowedAbsPath($this->filePath)
-            && GeneralUtility::isFirstPartOfStr($this->filePath, PATH_site . self::FILE_LOCK_FOLDER)
+            && GeneralUtility::isFirstPartOfStr($this->filePath, Environment::getVarPath() . '/' . self::FILE_LOCK_FOLDER)
         ) {
             if (@unlink($this->filePath) === false) {
                 $success = false;
index 5ec8b99..625dfab 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Log\Writer;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException;
 use TYPO3\CMS\Core\Log\LogLevel;
 use TYPO3\CMS\Core\Log\LogRecord;
@@ -37,7 +38,7 @@ class FileWriter extends AbstractWriter
      *
      * @var string
      */
-    protected $defaultLogFileTemplate = 'typo3temp/var/logs/typo3_%s.log';
+    protected $defaultLogFileTemplate = '/log/typo3_%s.log';
 
     /**
      * Log file handle storage
@@ -232,6 +233,6 @@ class FileWriter extends AbstractWriter
      */
     protected function getDefaultLogFileName()
     {
-        return sprintf($this->defaultLogFileTemplate, substr(GeneralUtility::hmac($this->defaultLogFileTemplate, 'defaultLogFile'), 0, 10));
+        return Environment::getVarPath() . sprintf($this->defaultLogFileTemplate, substr(GeneralUtility::hmac($this->defaultLogFileTemplate, 'defaultLogFile'), 0, 10));
     }
 }
index 68e835c..5db907e 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource\OnlineMedia\Helpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\DuplicationBehavior;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\Folder;
@@ -118,7 +119,7 @@ abstract class AbstractOnlineMediaHelper implements OnlineMediaHelperInterface
      */
     protected function getTempFolderPath()
     {
-        $path = PATH_site . 'typo3temp/var/transient/';
+        $path = Environment::getVarPath() . '/transient/';
         if (!is_dir($path)) {
             GeneralUtility::mkdir_deep($path);
         }
index 938d54e..3cb2798 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource\OnlineMedia\Processing;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
 use TYPO3\CMS\Core\Resource\File;
@@ -77,7 +78,7 @@ class PreviewProcessing
         if (empty($temporaryFileName) || !file_exists($temporaryFileName)) {
             return;
         }
-        $temporaryFileNameForResizedThumb = uniqid(PATH_site . 'typo3temp/var/transient/online_media_' . $file->getHashedIdentifier()) . '.jpg';
+        $temporaryFileNameForResizedThumb = uniqid(Environment::getVarPath() . '/transient/online_media_' . $file->getHashedIdentifier()) . '.jpg';
         $configuration = $processedFile->getProcessingConfiguration();
         switch ($taskType) {
             case ProcessedFile::CONTEXT_IMAGEPREVIEW:
index 8596efd..6c81c57 100644 (file)
@@ -19,6 +19,7 @@ use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerInterface;
 use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Http\RequestFactory;
 use TYPO3\CMS\Core\Log\LogLevel;
 use TYPO3\CMS\Core\Log\LogManager;
@@ -3076,7 +3077,7 @@ class GeneralUtility
         } elseif (!static::isAbsPath($filename)) {
             // is relative. Prepended with PATH_site
             $filename = PATH_site . $filename;
-        } elseif (!static::isFirstPartOfStr($filename, PATH_site)) {
+        } elseif (!static::isFirstPartOfStr($filename, Environment::getProjectPath())) {
             // absolute, but set to blank if not allowed
             $filename = '';
         }
@@ -3125,7 +3126,7 @@ class GeneralUtility
     {
         $lockRootPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'];
         return static::isAbsPath($path) && static::validPathStr($path)
-            && (static::isFirstPartOfStr($path, PATH_site)
+            && (static::isFirstPartOfStr($path, Environment::getProjectPath())
                 || $lockRootPath && static::isFirstPartOfStr($path, $lockRootPath));
     }
 
@@ -3243,7 +3244,7 @@ class GeneralUtility
     }
 
     /**
-     * Will move an uploaded file (normally in "/tmp/xxxxx") to a temporary filename in PATH_site."typo3temp/" from where TYPO3 can use it.
+     * Will move an uploaded file (normally in "/tmp/xxxxx") to a temporary filename in Environment::getProjectPath() . "var/" from where TYPO3 can use it.
      * Use this function to move uploaded files to where you can work on them.
      * REMEMBER to use \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile() afterwards - otherwise temp-files will build up! They are NOT automatically deleted in PATH_site."typo3temp/"!
      *
@@ -3275,7 +3276,10 @@ class GeneralUtility
             $uploadedTempFileName = self::fixWindowsFilePath($uploadedTempFileName);
             if (
                 self::validPathStr($uploadedTempFileName)
-                && self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/')
+                && (
+                    self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/')
+                    || self::isFirstPartOfStr($uploadedTempFileName, Environment::getVarPath() . '/')
+                )
                 && @is_file($uploadedTempFileName)
             ) {
                 if (unlink($uploadedTempFileName)) {
@@ -3297,7 +3301,7 @@ class GeneralUtility
      */
     public static function tempnam($filePrefix, $fileSuffix = '')
     {
-        $temporaryPath = PATH_site . 'typo3temp/var/transient/';
+        $temporaryPath = Environment::getVarPath() . '/transient/';
         if (!is_dir($temporaryPath)) {
             self::mkdir_deep($temporaryPath);
         }
index b453f91..6f30635 100644 (file)
@@ -21,7 +21,8 @@ As runtime reflection has been removed completely, along with it several reflect
 analyzed doc blocks, have been removed as well. These are no longer necessary.
 
 The `extbase_reflection` cache is no longer plugin based and will no longer be stored in the database
-in the first place. Serialized ClassSchema instances will be stored in `typo3temp/var/Cache`.
+in the first place. Serialized ClassSchema instances will be stored in `typo3temp/var/cache` or `var/cache` for
+composer-based installations.
 
 The following classes for internal use only and have been removed:
 
index 3025e6a..12417f1 100644 (file)
@@ -49,6 +49,7 @@ Impact
   analyzed doc blocks, have been removed as well. These are no longer necessary.
 
 * The `extbase_reflection` cache is no longer plugin based and will no longer be stored in the
-  database in the first place. Serialized `ClassSchema` instances will be stored in `typo3temp/var/Cache`.
+  database in the first place. Serialized `ClassSchema` instances will be stored in `typo3temp/var/cache` or
+  `var/cache/` for composer-based installations.
 
 .. index:: PHP-API, ext:extbase
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-84545-AllowTemporaryFilesToBeStoredOutsideTheDocumentRoot.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-84545-AllowTemporaryFilesToBeStoredOutsideTheDocumentRoot.rst
new file mode 100644 (file)
index 0000000..e9bd24c
--- /dev/null
@@ -0,0 +1,56 @@
+.. include:: ../../Includes.txt
+
+==============================================================================
+Feature: #84545 - Allow temporary files to be stored outside the document root
+==============================================================================
+
+See :issue:`84545`
+
+Description
+===========
+
+The environment variable called `TYPO3_PATH_APP`, which was previously introduced with the Environment
+API, is now used to allow to store data outside of the document root.
+
+All regular composer-based installations now benefit from this functionality directly, as data which was
+previously stored and hard-coded within :file:`typo3temp/var/` is now stored within the project roots' folder
+:file:`var/`.
+
+For non-composer installations, it is possible to set the environment variable to a folder usually one level
+upwards than the regular web root. This increases security for any TYPO3 installation as files are not
+publicly accessible (for example via web browser) anymore.
+
+A typical example:
+- `TYPO3_PATH_APP` is set to :file:`/var/www/my-project`.
+- The web folder is then set to `TYPO3_PATH_ROOT` :file:`/var/www/my-project/public`.
+
+Non-public files are then put to
+- :file:`/var/www/my-project/var/session` (like Install Tool Session files)
+- :file:`/var/www/my-project/var/cache` (Caching Framework data)
+- :file:`/var/www/my-project/var/lock` (Files related to locking)
+- :file:`/var/www/my-project/var/log` (Files related to logging)
+- :file:`/var/www/my-project/var/extensionmanager` (Files related to extension manager data)
+- :file:`/var/www/my-project/var/transient` (Files related to import/export, core updater, FAL)
+
+If the option is not set, the :file:`typo3temp/var/` folder is still used, but with some minor differences
+regarding the naming scheme of the folders.
+
+
+Impact
+======
+
+For installations having the environment variable set, the folder is now not within :file:`typo3temp/var/` anymore
+but outside of the document root in a folder called :file:`var/`.
+
+For installations without this setting in use, there are minor differences in the folder structure:
+- :file:`typo3temp/var/cache` is now used instead of :file:`typo3temp/var/Cache`
+- :file:`typo3temp/var/log` is now used instead of :file:`typo3temp/var/log`
+- :file:`typo3temp/var/lock` is now used instead of :file:`typo3temp/var/locks`
+- :file:`typo3temp/var/session` is now used instead of :file:`typo3temp/var/InstallToolSessions`
+- :file:`typo3temp/var/extensionmanager` is now used instead of :file:`typo3temp/var/ExtensionManager`
+
+Although it is a most common understanding in the TYPO3 world that `typo3temp/` can be removed at any time,
+it is considered bad practice to remove the whole folder. Only folders relevant for the current development
+changes should selectively be removed.
+
+.. index:: CLI, PHP-API
index 928355a..33a1667 100644 (file)
@@ -172,7 +172,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->setCacheDirectory('vfs://Foo/');
         $backend->setCache($mockCache);
 
-        $this->assertEquals('vfs://Foo/Cache/Data/SomeCache/', $backend->getCacheDirectory());
+        $this->assertEquals('vfs://Foo/cache/data/SomeCache/', $backend->getCacheDirectory());
     }
 
     /**
@@ -190,7 +190,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->setCacheDirectory('vfs://Foo/');
         $backend->setCache($mockCache);
 
-        $this->assertEquals('vfs://Foo/Cache/Code/SomeCache/', $backend->getCacheDirectory());
+        $this->assertEquals('vfs://Foo/cache/code/SomeCache/', $backend->getCacheDirectory());
     }
 
     /**
@@ -223,7 +223,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 
         $data = 'some data' . microtime();
         $entryIdentifier = 'BackendFileTest';
-        $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+        $pathAndFilename = 'vfs://Foo/cache/data/UnitTestCache/' . $entryIdentifier;
 
         $backend = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\Backend\FileBackend::class)
             ->setMethods(['dummy'])
@@ -261,7 +261,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->set($entryIdentifier, $data1, [], 500);
         $backend->set($entryIdentifier, $data2, [], 200);
 
-        $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+        $pathAndFilename = 'vfs://Foo/cache/data/UnitTestCache/' . $entryIdentifier;
         $this->assertFileExists($pathAndFilename);
         $retrievedData = file_get_contents($pathAndFilename, null, null, 0, strlen($data2));
         $this->assertEquals($data2, $retrievedData);
@@ -287,7 +287,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 
         $backend->set($entryIdentifier, $data, ['Tag1', 'Tag2']);
 
-        $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+        $pathAndFilename = 'vfs://Foo/cache/data/UnitTestCache/' . $entryIdentifier;
         $this->assertFileExists($pathAndFilename);
         $retrievedData = file_get_contents(
             $pathAndFilename,
@@ -373,7 +373,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             ->setMethods(['isCacheFileExpired'])
             ->disableOriginalConstructor()
             ->getMock();
-        $backend->expects($this->once())->method('isCacheFileExpired')->with('vfs://Foo/Cache/Data/UnitTestCache/ExpiredEntry')->will($this->returnValue(true));
+        $backend->expects($this->once())->method('isCacheFileExpired')->with('vfs://Foo/cache/data/UnitTestCache/ExpiredEntry')->will($this->returnValue(true));
         $backend->setCacheDirectory('vfs://Foo/');
         $backend->setCache($mockCache);
 
@@ -475,7 +475,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 
         $data = 'some data' . microtime();
         $entryIdentifier = 'BackendFileTest';
-        $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+        $pathAndFilename = 'vfs://Foo/cache/data/UnitTestCache/' . $entryIdentifier;
 
         $backend = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\Backend\FileBackend::class)
             ->setMethods(['dummy'])
@@ -736,13 +736,13 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->set('BackendFileTest1', $data);
         $backend->set('BackendFileTest2', $data);
 
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest1');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest2');
 
         $backend->flush();
 
-        $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-        $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+        $this->assertFileNotExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest1');
+        $this->assertFileNotExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest2');
     }
 
     /**
@@ -761,7 +761,7 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->setCache($mockCache);
 
         $backend->flush();
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/');
     }
 
     /**
@@ -802,12 +802,12 @@ class FileBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $backend->set('BackendFileTest1', $data);
         $backend->set('BackendFileTest2', $data);
 
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest1');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest2');
 
         $backend->collectGarbage();
-        $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-        $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+        $this->assertFileNotExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest1');
+        $this->assertFileExists('vfs://Foo/cache/data/UnitTestCache/BackendFileTest2');
     }
 
     /**
index d9f6c48..cba201a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Locking;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Locking\FileLockStrategy;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -27,9 +28,9 @@ class FileLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function constructorCreatesLockDirectoryIfNotExisting()
     {
-        GeneralUtility::rmdir(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER, true);
+        GeneralUtility::rmdir(Environment::getVarPath() . '/' . FileLockStrategy::FILE_LOCK_FOLDER, true);
         new FileLockStrategy('999999999');
-        $this->assertTrue(is_dir(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER));
+        $this->assertTrue(is_dir(Environment::getVarPath() . '/' . FileLockStrategy::FILE_LOCK_FOLDER));
     }
 
     /**
@@ -38,6 +39,6 @@ class FileLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
     public function constructorSetsFilePathToExpectedValue()
     {
         $lock = $this->getAccessibleMock(FileLockStrategy::class, ['dummy'], ['999999999']);
-        $this->assertSame(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER . 'flock_' . md5('999999999'), $lock->_get('filePath'));
+        $this->assertSame(Environment::getVarPath() . '/' . FileLockStrategy::FILE_LOCK_FOLDER . 'flock_' . md5('999999999'), $lock->_get('filePath'));
     }
 }
index 668a956..95a59ff 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Unit\Locking;
  * The TYPO3 project - inspiring people to share!
  */
 
+use PHPUnit\Framework\SkippedTestError;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Locking\SimpleLockStrategy;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -27,9 +29,9 @@ class SimpleLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      */
     public function constructorCreatesLockDirectoryIfNotExisting()
     {
-        GeneralUtility::rmdir(PATH_site . SimpleLockStrategy::FILE_LOCK_FOLDER, true);
+        GeneralUtility::rmdir(Environment::getVarPath() . '/' . SimpleLockStrategy::FILE_LOCK_FOLDER, true);
         new SimpleLockStrategy('999999999');
-        $this->assertTrue(is_dir(PATH_site . SimpleLockStrategy::FILE_LOCK_FOLDER));
+        $this->assertTrue(is_dir(Environment::getVarPath() . '/' . SimpleLockStrategy::FILE_LOCK_FOLDER));
     }
 
     /**
@@ -38,7 +40,7 @@ class SimpleLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     public function constructorSetsResourceToPathWithIdIfUsingSimpleLocking()
     {
         $lock = $this->getAccessibleMock(SimpleLockStrategy::class, ['dummy'], ['999999999']);
-        $this->assertSame(PATH_site . SimpleLockStrategy::FILE_LOCK_FOLDER . 'simple_' . md5('999999999'), $lock->_get('filePath'));
+        $this->assertSame(Environment::getVarPath() . '/' . SimpleLockStrategy::FILE_LOCK_FOLDER . 'simple_' . md5('999999999'), $lock->_get('filePath'));
     }
 
     /**
@@ -88,9 +90,9 @@ class SimpleLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     {
         return [
             'not within PATH_site' => [tempnam(sys_get_temp_dir(), 'foo')],
-            'directory traversal' => [PATH_site . 'typo3temp/../typo3temp/var/locks/foo'],
-            'directory traversal 2' => [PATH_site . 'typo3temp/var/locks/../../var/locks/foo'],
-            'within uploads' => [PATH_site . 'uploads/TYPO3-Lock-Test']
+            'directory traversal' => [Environment::getVarPath() . '/../var/lock/foo'],
+            'directory traversal 2' => [Environment::getVarPath() . '/lock/../../var/lock/foo'],
+            'within uploads' => [Environment::getPublicPath() . '/uploads/TYPO3-Lock-Test']
         ];
     }
 
@@ -98,7 +100,7 @@ class SimpleLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      * @test
      * @dataProvider invalidFileReferences
      * @param string $file
-     * @throws \PHPUnit_Framework_SkippedTestError
+     * @throws SkippedTestError
      */
     public function releaseDoesNotRemoveFilesNotWithinTypo3TempLocksDirectory($file)
     {
index 816bae6..f4f9776 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Mail;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Mail\MemorySpool;
 use TYPO3\CMS\Core\Mail\TransportFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -90,7 +91,7 @@ class TransportFactoryTest extends UnitTestCase
             'defaultMailFromAddress' => '',
             'defaultMailFromName' => '',
             'transport_spool_type' => 'memory',
-            'transport_spool_filepath' => 'typo3temp/var/messages/',
+            'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
         // Register fixture class
@@ -121,7 +122,7 @@ class TransportFactoryTest extends UnitTestCase
             'defaultMailFromAddress' => '',
             'defaultMailFromName' => '',
             'transport_spool_type' => 'TYPO3\\CMS\\Core\\Tests\\Unit\\Mail\\Fixtures\\FakeValidSpoolFixture',
-            'transport_spool_filepath' => 'typo3temp/var/messages/',
+            'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
         /** @var \Swift_SpoolTransport $transport */
@@ -154,7 +155,7 @@ class TransportFactoryTest extends UnitTestCase
             'defaultMailFromAddress' => '',
             'defaultMailFromName' => '',
             'transport_spool_type' => 'TYPO3\\CMS\\Core\\Tests\\Unit\\Mail\\Fixtures\\FakeInvalidSpoolFixture',
-            'transport_spool_filepath' => 'typo3temp/var/messages/',
+            'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
         $this->subject->get($mailSettings);
@@ -176,7 +177,7 @@ class TransportFactoryTest extends UnitTestCase
             'defaultMailFromAddress' => '',
             'defaultMailFromName' => '',
             'transport_spool_type' => '',
-            'transport_spool_filepath' => 'typo3temp/var/messages/',
+            'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
         $transport = $this->subject->get($mailSettings);
index b4314c4..c6dc87f 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Documentation\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Http\RequestFactory;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -43,7 +44,7 @@ class DocumentationService
             }
 
             // Cache file locally to be able to create a composer.json file when fetching a document
-            $absoluteCacheFilename = GeneralUtility::getFileAbsFileName('typo3temp/var/transient/documents.json');
+            $absoluteCacheFilename = Environment::getVarPath() . '/transient/documents.json';
             GeneralUtility::writeFileToTypo3tempDir($absoluteCacheFilename, $json);
         }
         return $documents;
@@ -170,7 +171,7 @@ class DocumentationService
         $languageSegment = str_replace('_', '-', strtolower($language));
         $packageName = sprintf('%s-%s-%s.zip', $packagePrefix, $version, $languageSegment);
         $packageUrl = $url . 'packages/' . $packageName;
-        $absolutePathToZipFile = GeneralUtility::getFileAbsFileName('typo3temp/var/transient/' . $packageName);
+        $absolutePathToZipFile = Environment::getVarPath() . '/transient/' . $packageName;
 
         $packages = $this->getAvailablePackages($url);
         if (empty($packages) || !isset($packages[$version][$language])) {
@@ -200,7 +201,7 @@ class DocumentationService
             $result = $this->unzipDocumentPackage($absolutePathToZipFile, $absoluteDocumentPath);
 
             // Create a composer.json file
-            $absoluteCacheFilename = GeneralUtility::getFileAbsFileName('typo3temp/var/transient/documents.json');
+            $absoluteCacheFilename = Environment::getVarPath() . '/transient/documents.json';
             $documents = json_decode(file_get_contents($absoluteCacheFilename), true);
             foreach ($documents as $document) {
                 if ($document['key'] === $key) {
index cc03973..620ebcd 100644 (file)
@@ -309,7 +309,7 @@ class UploadExtensionFileController extends AbstractController
      */
     protected function copyExtensionFolderToTempFolder($extensionKey)
     {
-        $this->extensionBackupPath = PATH_site . 'typo3temp/var/transient/' . $extensionKey . substr(sha1($extensionKey . microtime()), 0, 7) . '/';
+        $this->extensionBackupPath = Environment::getVarPath() . '/transient/' . $extensionKey . substr(sha1($extensionKey . microtime()), 0, 7) . '/';
         GeneralUtility::mkdir($this->extensionBackupPath);
         GeneralUtility::copyDirectory(
             $this->fileHandlingUtility->getExtensionDir($extensionKey),
index 8cf13f2..e145861 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace TYPO3\CMS\Extensionmanager\Utility;
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
@@ -418,10 +419,11 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface
             $version = '0.0.0';
         }
 
-        if (!@is_dir(PATH_site . 'typo3temp/var/ExtensionManager/')) {
-            GeneralUtility::mkdir(PATH_site . 'typo3temp/var/ExtensionManager/');
+        $temporaryPath = Environment::getVarPath() . '/transient/';
+        if (!@is_dir($temporaryPath)) {
+            GeneralUtility::mkdir($temporaryPath);
         }
-        $fileName = $this->getAbsolutePath('typo3temp/var/ExtensionManager/' . $extension . '_' . $version . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip');
+        $fileName = $temporaryPath . $extension . '_' . $version . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip';
 
         $zip = new \ZipArchive();
         $zip->open($fileName, \ZipArchive::CREATE);
index 60c680d..1772aa9 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility\Repository;
  */
 
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
@@ -161,7 +162,7 @@ class Helper implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getLocalExtListFile()
     {
-        return PATH_site . 'typo3temp/var/ExtensionManager/' . (int)$this->repository->getUid() . '.extensions.xml.gz';
+        return Environment::getVarPath() . '/extensionmanager/' . (int)$this->repository->getUid() . '.extensions.xml.gz';
     }
 
     /**
@@ -201,7 +202,7 @@ class Helper implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getLocalMirrorListFile()
     {
-        return PATH_site . 'typo3temp/var/ExtensionManager/' . (int)$this->repository->getUid() . '.mirrors.xml.gz';
+        return Environment::getVarPath() . '/extensionmanager/' . (int)$this->repository->getUid() . '.mirrors.xml.gz';
     }
 
     /**
index 811395f..dacc136 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
 
@@ -105,7 +106,7 @@ class UpdateScriptUtility
         if (!preg_match('/<\?php.*namespace\s+([^;]+);.*class/is', $scriptSourceCode, $matches)) {
             // if no, rename the class with a unique name
             $className = 'ext_update' . md5($extensionKey . $scriptSourceCode);
-            $temporaryFileName = PATH_site . 'typo3temp/var/transient/' . $className . '.php';
+            $temporaryFileName = Environment::getVarPath() . '/transient/' . $className . '.php';
             if (!file_exists(GeneralUtility::getFileAbsFileName($temporaryFileName))) {
                 $scriptSourceCode = preg_replace('/^\s*class\s+ext_update\s+/m', 'class ' . $className . ' ', $scriptSourceCode);
                 GeneralUtility::writeFileToTypo3tempDir($temporaryFileName, $scriptSourceCode);
index dffce0f..3ed8ece 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
@@ -583,7 +584,7 @@ class FileHandlingUtilityTest extends UnitTestCase
         // Create zip-file from extension
         $filename = $fileHandlerMock->_call('createZipFileFromExtension', $extKey);
 
-        $expectedFilename = PATH_site . 'typo3temp/var/ExtensionManager/' . $extKey . '_0.0.0_' . date('YmdHi', 42) . '.zip';
+        $expectedFilename = Environment::getVarPath() . '/transient/' . $extKey . '_0.0.0_' . date('YmdHi', 42) . '.zip';
         $this->testFilesToDelete[] = $filename;
         $this->assertEquals($expectedFilename, $filename, 'Archive file name differs from expectation');
 
index c8d43a2..de6f79b 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Impexp;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
@@ -953,7 +954,7 @@ abstract class ImportExport
      */
     protected function getTemporaryFolderName()
     {
-        $temporaryPath = PATH_site . 'typo3temp/var/transient/';
+        $temporaryPath = Environment::getVarPath() . '/transient/';
         do {
             $temporaryFolderName = $temporaryPath . 'export_temp_files_' . mt_rand(1, PHP_INT_MAX);
         } while (is_dir($temporaryFolderName));
index a26f6d3..842152f 100644 (file)
@@ -118,7 +118,7 @@ class MaintenanceController extends AbstractController
             $failedDeletions = $typo3tempFileService->clearProcessedFiles();
             if ($failedDeletions) {
                 $messageQueue->enqueue(new FlashMessage(
-                    'Failed to delete ' . $failedDeletions . ' processed files. See TYPO3 log (by default typo3temp/var/logs/typo3_*.log)',
+                    'Failed to delete ' . $failedDeletions . ' processed files. See TYPO3 log (by default typo3temp/var/log/typo3_*.log)',
                     '',
                     FlashMessage::ERROR
                 ));
index 0cb5d14..daa9c46 100644 (file)
@@ -107,12 +107,12 @@ class DefaultFactory
                                     'targetPermission' => $directoryPermission,
                                 ],
                                 [
-                                    'name' => 'Cache',
+                                    'name' => 'cache',
                                     'type' => DirectoryNode::class,
                                     'targetPermission' => $directoryPermission,
                                 ],
                                 [
-                                    'name' => 'locks',
+                                    'name' => 'lock',
                                     'type' => DirectoryNode::class,
                                     'targetPermission' => $directoryPermission,
                                 ]
index 85a1cb4..a2d8666 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\Exception;
@@ -54,38 +55,42 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
         //  0 = not required, if it exists the dir should be writable
         //  1 = required, doesn't have to be writable
         //  2 = required, has to be writable
+        $varPath = Environment::getVarPath();
+        $sitePath = Environment::getPublicPath();
+        $rootPath = Environment::getProjectPath();
         $checkWritable = [
-            'typo3temp/' => 2,
-            'typo3temp/assets/' => 2,
-            'typo3temp/assets/compressed/' => 2,
+            $sitePath . '/typo3temp/' => 2,
+            $sitePath . '/typo3temp/assets/' => 2,
+            $sitePath . '/typo3temp/assets/compressed/' => 2,
             // only needed when GraphicalFunctions is used
-            'typo3temp/assets/images/' => 0,
+            $sitePath . '/typo3temp/assets/images/' => 0,
             // used in PageGenerator (inlineStyle2Temp) and Backend + Language JS files
-            'typo3temp/assets/css/' => 2,
-            'typo3temp/assets/js/' => 2,
+            $sitePath . '/typo3temp/assets/css/' => 2,
+            $sitePath . '/typo3temp/assets/js/' => 2,
             // fallback storage of FAL
-            'typo3temp/assets/_processed_/' => 0,
-            'typo3temp/var/' => 2,
-            'typo3temp/var/transient/' => 2,
-            'typo3temp/var/charset/' => 2,
-            'typo3temp/var/locks/' => 2,
-            'typo3conf/' => 2,
-            'typo3conf/ext/' => 0,
-            'typo3conf/l10n/' => 0,
-            $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
-            $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
+            $sitePath . '/typo3temp/assets/_processed_/' => 0,
+            $varPath => 2,
+            $varPath . '/transient/' => 2,
+            $varPath . '/charset/' => 2,
+            $varPath . '/lock/' => 2,
+            $sitePath . '/typo3conf/' => 2,
+            $sitePath . '/typo3conf/ext/' => 0,
+            $sitePath . '/typo3conf/l10n/' => 0,
+            $sitePath . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
+            $sitePath . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
         ];
 
         if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall']) {
             $checkWritable[TYPO3_mainDir . 'ext/'] = -1;
         }
 
-        foreach ($checkWritable as $relPath => $requirementLevel) {
-            if (!@is_dir(PATH_site . $relPath)) {
+        foreach ($checkWritable as $path => $requirementLevel) {
+            $relPath = substr($path, strlen($rootPath) + 1);
+            if (!@is_dir($path)) {
                 // If the directory is missing, try to create it
-                GeneralUtility::mkdir(PATH_site . $relPath);
+                GeneralUtility::mkdir($path);
             }
-            if (!@is_dir(PATH_site . $relPath)) {
+            if (!@is_dir($path)) {
                 if ($requirementLevel > 0) {
                     // directory is required
                     $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
@@ -103,12 +108,12 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
                     }
                 }
             } else {
-                if (!is_writable(PATH_site . $relPath)) {
+                if (!is_writable($path)) {
                     switch ($requirementLevel) {
                         case 0:
                             $message .= sprintf(
                                 $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'),
-                                    PATH_site . $relPath
+                                    $path
                             ) . '<br />';
                             if ($severity < Status::WARNING) {
                                 $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
@@ -119,7 +124,7 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
                             $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
                             $message .= sprintf(
                                 $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'),
-                                    PATH_site . $relPath
+                                    $path
                             ) . '<br />';
                             $severity = Status::ERROR;
                             break;
index 52a5ee5..8f1fe16 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Service;
  */
 
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -40,7 +41,7 @@ class ClearCacheService
     public function clearAll()
     {
         // Delete typo3temp/Cache
-        GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true, true);
+        GeneralUtility::flushDirectory(Environment::getVarPath() . '/cache', true, true);
 
         // Get all table names from Default connection starting with 'cf_' and truncate them
         $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
index 88c44f1..c05371d 100644 (file)
@@ -73,7 +73,7 @@ class CoreUpdateService
     public function __construct(CoreVersionService $coreVersionService = null)
     {
         $this->coreVersionService = $coreVersionService ?: GeneralUtility::makeInstance(CoreVersionService::class);
-        $this->setDownloadTargetPath(PATH_site . 'typo3temp/var/transient/');
+        $this->setDownloadTargetPath(Environment::getVarPath() . '/transient/');
         $this->symlinkToCoreFiles = $this->discoverCurrentCoreSymlink();
         $this->downloadBaseUri = $this->coreVersionService->getDownloadBaseUri();
         $this->messages = new FlashMessageQueue('install');
index 86f38d1..f19df56 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Install\Service;
  */
 
 use Symfony\Component\Finder\Finder;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\Locales;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Registry;
@@ -234,7 +235,7 @@ class LanguagePackService
         }
 
         $absoluteExtractionPath = GeneralUtility::getFileAbsFileName('typo3conf/l10n/' . $iso . '/' . $key . '/');
-        $absolutePathToZipFile = GeneralUtility::getFileAbsFileName('typo3temp/var/transient/' . $key . '-l10n-' . $iso . '.zip');
+        $absolutePathToZipFile = Environment::getVarPath() . '/transient/' . $key . '-l10n-' . $iso . '.zip';
 
         $packExists = is_dir($absoluteExtractionPath);
 
@@ -249,7 +250,7 @@ class LanguagePackService
                     $operationResult = GeneralUtility::rmdir($absoluteExtractionPath, true);
                 }
                 if ($operationResult) {
-                    GeneralUtility::mkdir_deep(GeneralUtility::getFileAbsFileName('typo3temp/var/transient/'));
+                    GeneralUtility::mkdir_deep(Environment::getVarPath() . '/transient/');
                     $operationResult = GeneralUtility::writeFileToTypo3tempDir($absolutePathToZipFile, $languagePackContent) === null;
                 }
                 $this->unzipTranslationFile($absolutePathToZipFile, $absoluteExtractionPath);
index b2eda36..3bf7348 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -24,7 +25,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class SessionService implements SingletonInterface
 {
     /**
-     * The path to our typo3temp/var/ (where we can write our sessions). Set in the
+     * The path to our var/ folder (where we can write our sessions). Set in the
      * constructor.
      *
      * @var string
@@ -32,12 +33,12 @@ class SessionService implements SingletonInterface
     private $basePath;
 
     /**
-     * Path where to store our session files in typo3temp. %s will be
+     * Path where to store our session files in var/session/. %s will be
      * non-guessable.
      *
      * @var string
      */
-    private $sessionPath = 'InstallToolSessions/%s';
+    private $sessionPath = 'session/%s';
 
     /**
      * the cookie to store the session ID of the install tool
@@ -67,7 +68,7 @@ class SessionService implements SingletonInterface
      */
     public function __construct()
     {
-        $this->basePath = PATH_site . 'typo3temp/var/';
+        $this->basePath = Environment::getVarPath() . '/';
         // Start our PHP session early so that hasSession() works
         $sessionSavePath = $this->getSessionSavePath();
         // Register our "save" session handler
@@ -129,7 +130,7 @@ class SessionService implements SingletonInterface
                 GeneralUtility::mkdir_deep($sessionSavePath);
             } catch (\RuntimeException $exception) {
                 throw new \TYPO3\CMS\Install\Exception(
-                    'Could not create session folder in typo3temp/. Make sure it is writeable!',
+                    'Could not create session folder in ' . Environment::getVarPath() . '. Make sure it is writeable!',
                     1294587484
                 );
             }
@@ -466,7 +467,8 @@ class SessionService implements SingletonInterface
         }
         if (!$result) {
             throw new Exception(
-                'Session file not writable. Please check permission on typo3temp/var/InstallToolSessions and its subdirectories.',
+                'Session file not writable. Please check permission on ' .
+                Environment::getVarPath() . '/session and its subdirectories.',
                 1424355157
             );
         }
index 487c099..6170a9c 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Rsaauth\Backend;
  */
 
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
@@ -41,7 +42,7 @@ class CommandLineBackend extends AbstractBackend
     /**
      * Temporary directory. It is best of it is outside of the web site root and
      * not publicly readable.
-     * For now we use typo3temp/var/ (stored in the variable without the trailing slash).
+     * For now we use Environment::getVarPath() . '/transient' (stored in the variable without the trailing slash).
      *
      * @var string
      */
@@ -59,7 +60,7 @@ class CommandLineBackend extends AbstractBackend
         if ($path !== '' && $path[0] === '/' && @is_dir($path) && is_writable($path)) {
             $this->temporaryDirectory = $path;
         } else {
-            $this->temporaryDirectory = PATH_site . 'typo3temp/var/transient';
+            $this->temporaryDirectory = Environment::getVarPath() . '/transient';
         }
     }
 
index 84f31b9..9759e2f 100644 (file)
@@ -18,6 +18,7 @@ use Doctrine\DBAL\DBALException;
 use Doctrine\DBAL\Platforms\SQLServerPlatform;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
@@ -827,7 +828,7 @@ class DataHandlerHook
             return;
         }
         // Lock file name:
-        $lockFileName = PATH_site . 'typo3temp/var/swap_locking/' . $table . '_' . $id . '.ser';
+        $lockFileName = Environment::getVarPath() . '/lock/swap' . $table . '_' . $id . '.ser';
         if (@is_file($lockFileName)) {
             $dataHandler->newlog('A swapping lock file was present. Either another swap process is already running or a previous swap process failed. Ask your administrator to handle the situation.', 2);
             return;