[TASK] Revert "Move LocalConfiguration* files to config folder" 47/58147/4
authorBenni Mack <benni@typo3.org>
Mon, 3 Sep 2018 17:36:42 +0000 (19:36 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Mon, 3 Sep 2018 19:15:03 +0000 (21:15 +0200)
This reverts commit 277c677a967fcca5a158042465bfe35da9a3fa15.

This change was meant as a pre-cursor to the new config handling,
which needs some more thoughts on how to deal with AdditionalConfiguration.php
in the future, and is reverted for the time being.

Resolves: #86115
Reverts: #84623
Releases: master
Change-Id: Ib46666856b3ed797f574f10f2af024d29bdad956
Reviewed-on: https://review.typo3.org/58147
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
12 files changed:
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Configuration/FactoryConfiguration.php
typo3/sysext/core/Documentation/Changelog/9.4/Important-84623-ConfigurationFilesMovedFromTypo3confToConfigDirectory.rst [deleted file]
typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/install/Classes/Controller/InstallerController.php
typo3/sysext/install/Classes/Controller/LoginController.php
typo3/sysext/install/Classes/Http/Application.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
typo3/sysext/install/Resources/Private/Templates/Login/ShowLogin.html

index 4003b59..f444467 100644 (file)
@@ -26,8 +26,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * This class handles the access to the files
  * - EXT:core/Configuration/DefaultConfiguration.php (default TYPO3_CONF_VARS)
- * - LocalConfiguration.php (overrides of TYPO3_CONF_VARS)
- * - AdditionalConfiguration.php (optional additional local code blocks)
+ * - typo3conf/LocalConfiguration.php (overrides of TYPO3_CONF_VARS)
+ * - typo3conf/AdditionalConfiguration.php (optional additional local code blocks)
  *
  * IMPORTANT:
  *   This class is intended for internal core use ONLY.
@@ -48,14 +48,14 @@ class ConfigurationManager
     protected $defaultConfigurationDescriptionFile = 'typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml';
 
     /**
-     * @var string Path to local overload TYPO3_CONF_VARS file, relative to Environment::getConfigPath()
+     * @var string Path to local overload TYPO3_CONF_VARS file, relative to the public web folder
      */
-    protected $localConfigurationFile = 'LocalConfiguration.php';
+    protected $localConfigurationFile = 'typo3conf/LocalConfiguration.php';
 
     /**
-     * @var string Path to additional local file, relative to Environment::getConfigPath()
+     * @var string Path to additional local file, relative to the public web folder
      */
-    protected $additionalConfigurationFile = 'AdditionalConfiguration.php';
+    protected $additionalConfigurationFile = 'typo3conf/AdditionalConfiguration.php';
 
     /**
      * @var string Path to factory configuration file used during installation as LocalConfiguration boilerplate
@@ -65,7 +65,7 @@ class ConfigurationManager
     /**
      * @var string Path to possible additional factory configuration file delivered by packages
      */
-    protected $additionalFactoryConfigurationFile = 'AdditionalFactoryConfiguration.php';
+    protected $additionalFactoryConfigurationFile = 'typo3conf/AdditionalFactoryConfiguration.php';
 
     /**
      * Writing to these configuration paths is always allowed,
@@ -117,7 +117,7 @@ class ConfigurationManager
     }
 
     /**
-     * Return local configuration array Environment::getConfigPath() / LocalConfiguration.php
+     * Return local configuration array typo3conf/LocalConfiguration.php
      *
      * @return array Content array of local configuration file
      */
@@ -135,7 +135,7 @@ class ConfigurationManager
      */
     public function getLocalConfigurationFileLocation()
     {
-        return Environment::getConfigPath() . '/' . $this->localConfigurationFile;
+        return Environment::getPublicPath() . '/' . $this->localConfigurationFile;
     }
 
     /**
@@ -159,7 +159,7 @@ class ConfigurationManager
      */
     public function getAdditionalConfigurationFileLocation()
     {
-        return Environment::getConfigPath() . '/' . $this->additionalConfigurationFile;
+        return Environment::getPublicPath() . '/' . $this->additionalConfigurationFile;
     }
 
     /**
@@ -179,7 +179,7 @@ class ConfigurationManager
      */
     protected function getAdditionalFactoryConfigurationFileLocation()
     {
-        return Environment::getConfigPath() . '/' . $this->additionalFactoryConfigurationFile;
+        return Environment::getPublicPath() . '/' . $this->additionalFactoryConfigurationFile;
     }
 
     /**
@@ -321,7 +321,7 @@ class ConfigurationManager
     public function canWriteConfiguration()
     {
         $fileLocation = $this->getLocalConfigurationFileLocation();
-        return @is_writable(file_exists($fileLocation) ? $fileLocation : Environment::getConfigPath());
+        return @is_writable(file_exists($fileLocation) ? $fileLocation : Environment::getPublicPath() . '/typo3conf/');
     }
 
     /**
@@ -351,7 +351,7 @@ class ConfigurationManager
     }
 
     /**
-     * Write local configuration array to Environment::getConfigPath() . /LocalConfiguration.php
+     * Write local configuration array to typo3conf/LocalConfiguration.php
      *
      * @param array $configuration The local configuration to be written
      * @throws \RuntimeException
@@ -383,7 +383,7 @@ class ConfigurationManager
     }
 
     /**
-     * Write additional configuration array to Environment::getConfigPath() . /AdditionalConfiguration.php
+     * Write additional configuration array to typo3conf/AdditionalConfiguration.php
      *
      * @param array $additionalConfigurationLines The configuration lines to be written
      * @throws \RuntimeException
@@ -401,7 +401,7 @@ class ConfigurationManager
 
     /**
      * Uses FactoryConfiguration file and a possible AdditionalFactoryConfiguration
-     * file in Environment::getConfigPath() to create a basic LocalConfiguration.php. This is used
+     * file in typo3conf to create a basic LocalConfiguration.php. This is used
      * by the install tool in an early step.
      *
      * @throws \RuntimeException
index 767c608..9638fea 100644 (file)
@@ -28,7 +28,7 @@ use TYPO3\CMS\Core\Utility\StringUtility;
  *
  * This class does not use any TYPO3 instance specific configuration, it only
  * sets up things based on the server environment and core code. Even with a
- * missing LocalConfiguration.php this script will be successful.
+ * missing typo3conf/localconf.php this script will be successful.
  *
  * The script aborts execution with an error message if
  * some part fails or conditions are not met.
index d0e27be..a82b4da 100644 (file)
@@ -109,7 +109,7 @@ class PackageManager implements SingletonInterface
     public function __construct(DependencyOrderingService $dependencyOrderingService = null)
     {
         $this->packagesBasePath = Environment::getPublicPath() . '/';
-        $this->packageStatesPathAndFilename = Environment::getLegacyConfigPath() . '/PackageStates.php';
+        $this->packageStatesPathAndFilename = Environment::getPublicPath() . '/typo3conf/PackageStates.php';
         if ($dependencyOrderingService === null) {
             trigger_error(self::class . ' without constructor based dependency injection has been deprecated in v9.2 and will not work in TYPO3 v10.', E_USER_DEPRECATED);
             $dependencyOrderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
index 1d9e568..23d6ad5 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 /**
- * This is a boilerplate of LocalConfiguration.php. It is
+ * This is a boilerplate of typo3conf/LocalConfiguration.php. It is
  * used as base file during installation and can be overloaded with
- * a package specific file AdditionalFactoryConfiguration.php
+ * a package specific file typo3conf/AdditionalFactoryConfiguration.php
  * from eg. the government or introduction package.
  */
 return [
diff --git a/typo3/sysext/core/Documentation/Changelog/9.4/Important-84623-ConfigurationFilesMovedFromTypo3confToConfigDirectory.rst b/typo3/sysext/core/Documentation/Changelog/9.4/Important-84623-ConfigurationFilesMovedFromTypo3confToConfigDirectory.rst
deleted file mode 100644 (file)
index 9ce2046..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-.. include:: ../../Includes.txt
-
-====================================================================================
-Important: #84623 - Configuration files moved from "typo3conf" to "config" directory
-====================================================================================
-
-See :issue:`84623`
-
-Description
-===========
-
-The TYPO3 configuration files for instances running in Composer Mode or having the environment
-variable `TYPO3_PATH_APP` set to a different location than :php:`PATH_site`, have been moved from
-the :file:`<web-dir>/typo3conf` to the :file:`config` directory.
-
-The following files are affected:
-
-- :file:`LocalConfiguration.php`
-- :file:`AdditionalConfiguration.php`
-- :file:`AdditionalFactoryConfiguration.php`
-
-The first access to the TYPO3 frontend or backend will redirect to the Install Tool which
-automatically creates the :file:`config` directory and moves all of the affected files currently
-present in :file:`<web-dir>/typo3conf` to :file:`config`. Afterwards backend and frontend are
-accessible as usual.
-
-Using the environment variable `TYPO3_PATH_APP` allows for storing relevant code like configuration
-outside of the document root / Composer `<web-dir>`. This effectively hardens a TYPO3 instance,
-as less files are accessible in public. All new installations in Composer Mode use this setup by
-default. Installations in Classic Mode (without Composer setup) will continue to use the previous
-setup since it cannot be ensured that they have access outside of the document root.
-
-If you have a setup with a :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern']` set, please
-go to the install tool first. The migration is done automatically and you can just go to the backend
-afterwards. If you have not set your trustedHostsPattern, you will be redirected automatically and
-you don't have to do anything.
-
-.. index:: LocalConfiguration
index 7b7b6f4..160aa9c 100644 (file)
@@ -378,7 +378,7 @@ class ConfigurationManagerTest extends UnitTestCase
             $this->markTestSkipped('Test skipped if run on linux as root');
         }
         /** @var $subject ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['getLocalConfigurationFileLocation']);
+        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $file = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
         $absoluteFile = Environment::getPublicPath() . '/' . $file;
@@ -387,9 +387,7 @@ class ConfigurationManagerTest extends UnitTestCase
         chmod($absoluteFile, 0444);
         clearstatcache();
 
-        $subject
-            ->method('getLocalConfigurationFileLocation')
-            ->will($this->returnValue($absoluteFile));
+        $subject->_set('localConfigurationFile', $file);
 
         $result = $subject->canWriteConfiguration();
 
@@ -404,7 +402,7 @@ class ConfigurationManagerTest extends UnitTestCase
     public function canWriteConfigurationReturnsTrueIfDirectoryAndFilesAreWritable(): void
     {
         /** @var $subject ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['getLocalConfigurationFileLocation']);
+        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $directory = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
         $absoluteDirectory = Environment::getPublicPath() . '/' . $directory;
@@ -414,12 +412,10 @@ class ConfigurationManagerTest extends UnitTestCase
         $absoluteFile1 = Environment::getPublicPath() . '/' . $file;
         touch($absoluteFile1);
         $this->testFilesToDelete[] = $absoluteFile1;
+        $subject->_set('localConfigurationFile', $absoluteFile1);
+
         clearstatcache();
 
-        $subject
-            ->expects($this->any())
-            ->method('getLocalConfigurationFileLocation')
-            ->will($this->returnValue($absoluteFile1));
         $result = $subject->canWriteConfiguration();
 
         $this->assertTrue($result);
@@ -475,16 +471,13 @@ class ConfigurationManagerTest extends UnitTestCase
         $this->expectException(\RuntimeException::class);
 
         /** @var $subject ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['getLocalConfigurationFileLocation']);
+        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $file = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
         $absoluteFile = Environment::getPublicPath() . '/' . $file;
         touch($absoluteFile);
         $this->testFilesToDelete[] = $absoluteFile;
-        $subject
-            ->expects($this->any())
-            ->method('getLocalConfigurationFileLocation')
-            ->will($this->returnValue($absoluteFile));
+        $subject->_set('localConfigurationFile', $file);
 
         $subject->createLocalConfigurationFromFactoryConfiguration();
     }
@@ -495,11 +488,8 @@ class ConfigurationManagerTest extends UnitTestCase
     public function createLocalConfigurationFromFactoryConfigurationWritesContentFromFactoryFile(): void
     {
         /** @var $subject ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['writeLocalConfiguration', 'getLocalConfigurationFileLocation']);
-        $subject
-            ->expects($this->any())
-            ->method('getLocalConfigurationFileLocation')
-            ->will($this->returnValue(PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dummy_')));
+        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['writeLocalConfiguration']);
+        $subject->_set('localConfigurationFile', 'typo3temp/var/tests/' . $this->getUniqueId('dummy_'));
 
         $factoryConfigurationFile = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.php';
         $factoryConfigurationAbsoluteFile = Environment::getPublicPath() . '/' . $factoryConfigurationFile;
@@ -530,11 +520,8 @@ class ConfigurationManagerTest extends UnitTestCase
     public function createLocalConfigurationFromFactoryConfigurationMergesConfigurationWithAdditionalFactoryFile(): void
     {
         /** @var $subject ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['writeLocalConfiguration', 'getAdditionalFactoryConfigurationFileLocation', 'getLocalConfigurationFileLocation']);
-        $subject
-            ->expects($this->any())
-            ->method('getLocalConfigurationFileLocation')
-            ->will($this->returnValue(PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dummy_')));
+        $subject = $this->getAccessibleMock(ConfigurationManager::class, ['writeLocalConfiguration']);
+        $subject->_set('localConfigurationFile', 'typo3temp/var/tests/' . $this->getUniqueId('dummy_'));
 
         $factoryConfigurationFile = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.php';
         $factoryConfigurationAbsoluteFile = Environment::getPublicPath() . '/' . $factoryConfigurationFile;
@@ -562,10 +549,6 @@ class ConfigurationManagerTest extends UnitTestCase
         );
         $this->testFilesToDelete[] = $additionalFactoryConfigurationAbsoluteFile;
         $subject->_set('additionalFactoryConfigurationFile', $additionalFactoryConfigurationFile);
-        $subject
-            ->expects($this->any())
-            ->method('getAdditionalFactoryConfigurationFileLocation')
-            ->will($this->returnValue($additionalFactoryConfigurationAbsoluteFile));
 
         $subject
             ->expects($this->once())
index 67201dd..623f005 100644 (file)
@@ -2261,7 +2261,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function getDirsReturnsArrayOfDirectoriesFromGivenDirectory()
     {
-        $directories = GeneralUtility::get_dirs(Environment::getBackendPath() . '/');
+        $directories = GeneralUtility::get_dirs(Environment::getLegacyConfigPath() . '/');
         $this->assertInternalType(\PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $directories);
     }
 
index 7e0ee87..21b0c57 100644 (file)
@@ -113,7 +113,7 @@ class InstallerController
     public function checkEnvironmentAndFoldersAction(): ResponseInterface
     {
         return new JsonResponse([
-            'success' => @is_file(Environment::getConfigPath() . '/LocalConfiguration.php'),
+            'success' => @is_file(Environment::getLegacyConfigPath() . '/LocalConfiguration.php'),
         ]);
     }
 
@@ -158,7 +158,7 @@ class InstallerController
         $structureFixMessageQueue = $structureFacade->fix();
         $errorsFromStructure = $structureFixMessageQueue->getAllMessages(FlashMessage::ERROR);
 
-        if (@is_dir(Environment::getConfigPath())) {
+        if (@is_dir(Environment::getLegacyConfigPath())) {
             $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
             $configurationManager->createLocalConfigurationFromFactoryConfiguration();
 
index 4d74486..65ad5fd 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Install\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
 use TYPO3\CMS\Core\Http\JsonResponse;
@@ -55,7 +54,6 @@ class LoginController extends AbstractController
         $view->assignMultiple([
             'siteName' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
             'loginToken' => $formProtection->generateToken('installTool', 'login'),
-            'configPath' => str_replace(Environment::getProjectPath(), '<project-path>', Environment::getConfigPath()),
         ]);
         return new JsonResponse([
             'success' => true,
index bbf6a4e..5ba6e3e 100644 (file)
@@ -24,7 +24,6 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Http\AbstractApplication;
 use TYPO3\CMS\Core\Http\RequestHandlerInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService;
 
 /**
  * Entry point for the TYPO3 Install Tool
@@ -59,12 +58,7 @@ class Application extends AbstractApplication
      */
     protected function handle(ServerRequestInterface $request): ResponseInterface
     {
-        // Migrate LocalConfiguration.php to a new file location, if TYPO3_PATH_APP is used.
-        // The functionality will be removed in TYPO3 v11.
-        GeneralUtility::makeInstance(SilentConfigurationUpgradeService::class)->migrateConfigurationFiles();
-
         $this->initializeContext();
-
         foreach ($this->availableRequestHandlers as $handler) {
             if ($handler->canHandleRequest($request)) {
                 return $handler->handleRequest($request);
index 356b890..501eb07 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Install\Service;
  */
 
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
-use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\BcryptPasswordHash;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface;
@@ -144,45 +143,6 @@ class SilentConfigurationUpgradeService
     }
 
     /**
-     * Migration wizard to move configuration files from "<web-dir>/typo3conf/" to "config/"
-     * This applies to the files where all installation-wide configuration resides,
-     * and is called each time when the installer is hit.
-     *
-     * This only applies if the environment variable "TYPO3_PATH_APP" is used and the new configuration
-     * files are not in place yet.
-     *
-     * This functionality will be removed in TYPO3 v11, as all installations should be migrated by then.
-     * @internal
-     */
-    public function migrateConfigurationFiles()
-    {
-        if (Environment::getConfigPath() !== rtrim(PATH_typo3conf, '/')) {
-            if (!file_exists(Environment::getConfigPath())) {
-                GeneralUtility::mkdir(Environment::getConfigPath());
-            }
-
-            $filesToCheck = [
-                'LocalConfiguration.php',
-                'AdditionalConfiguration.php',
-                'AdditionalFactoryConfiguration.php',
-            ];
-            $reloadConfiguration = false;
-            foreach ($filesToCheck as $filename) {
-                $oldFilepath = PATH_typo3conf . $filename;
-                $newFilepath = Environment::getConfigPath() . '/' . $filename;
-
-                if (file_exists($oldFilepath) && !file_exists($newFilepath)) {
-                    $reloadConfiguration = true;
-                    rename($oldFilepath, $newFilepath);
-                }
-            }
-            if ($reloadConfiguration) {
-                $this->configurationManager->exportConfiguration();
-            }
-        }
-    }
-
-    /**
      * Executed configuration upgrades. Single upgrade methods must throw a
      * ConfigurationChangedException if something was written to LocalConfiguration.
      *
index 57339a7..9e422b1 100644 (file)
@@ -37,7 +37,7 @@
                <div class="panel-heading"><h3 class="panel-title">Important</h3></div>
                <div class="panel-body">
                        If you don't know the current password, you can set a new one by setting the value of
-                       <code>$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']</code> in <code>{configPath}/LocalConfiguration.php</code> to
+                       <code>$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']</code> in <code>typo3conf/LocalConfiguration.php</code> to
                        the hash value of the password you desire, which will be shown if you enter the desired password
                        in this form and submit it.
                        <br /><br />