From 4b89b371d0f013b365bdffe7eec24689db9896f4 Mon Sep 17 00:00:00 2001
From: Garvin Hicking <gh@faktor-e.de>
Date: Thu, 13 Jun 2024 09:04:01 +0200
Subject: [PATCH] [TASK] Prevent requiring "typo3conf" for Composer mode in
 Dir. Status
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently both the Install Tool and Environment > Directory Status
sets the directory "typo3conf" as being mandatory and tries to
create it. This is no longer needed in Composer mode.

Resolves: #104074
Releases: main, 12.4
Change-Id: I880ec2b7ff0be642c2673bb7110ef95f3dc125d5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84637
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
---
 .../FolderStructure/DefaultFactory.php        | 70 ++++++++++---------
 .../Classes/Report/InstallStatusReport.php    |  3 +-
 2 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php b/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
index 97e941706520..e682cddbbc02 100644
--- a/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
+++ b/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
@@ -98,33 +98,6 @@ class DefaultFactory
                             ],
                         ],
                     ],
-                    [
-                        'name' => 'typo3conf',
-                        'type' => DirectoryNode::class,
-                        'targetPermission' => $directoryPermission,
-                        'children' => [
-                            [
-                                'name' => 'ext',
-                                'type' => DirectoryNode::class,
-                                'targetPermission' => $directoryPermission,
-                            ],
-                            [
-                                'name' => 'l10n',
-                                'type' => DirectoryNode::class,
-                                'targetPermission' => $directoryPermission,
-                            ],
-                            [
-                                'name' => 'sites',
-                                'type' => DirectoryNode::class,
-                                'targetPermission' => $directoryPermission,
-                            ],
-                            [
-                                'name' => 'system',
-                                'type' => DirectoryNode::class,
-                                'targetPermission' => $directoryPermission,
-                            ],
-                        ],
-                    ],
                     $this->getFileadminStructure(),
                 ],
             ];
@@ -145,6 +118,36 @@ class DefaultFactory
                     'targetContentFile' => self::TEMPLATE_PATH . '/root-web-config',
                 ];
             }
+
+            if (!Environment::isComposerMode()) {
+                $structure['children'][] = [
+                    'name' => 'typo3conf',
+                    'type' => DirectoryNode::class,
+                    'targetPermission' => $directoryPermission,
+                    'children' => [
+                        [
+                            'name' => 'ext',
+                            'type' => DirectoryNode::class,
+                            'targetPermission' => $directoryPermission,
+                        ],
+                        [
+                            'name' => 'l10n',
+                            'type' => DirectoryNode::class,
+                            'targetPermission' => $directoryPermission,
+                        ],
+                        [
+                            'name' => 'sites',
+                            'type' => DirectoryNode::class,
+                            'targetPermission' => $directoryPermission,
+                        ],
+                        [
+                            'name' => 'system',
+                            'type' => DirectoryNode::class,
+                            'targetPermission' => $directoryPermission,
+                        ],
+                    ],
+                ];
+            }
         } else {
             // This is when the public path is a subfolder (e.g. public/ or web/)
             $publicPath = substr(Environment::getPublicPath(), strlen(Environment::getProjectPath()) + 1);
@@ -164,11 +167,6 @@ class DefaultFactory
                         $this->getTemporaryAssetsFolderStructure(),
                     ],
                 ],
-                [
-                    'name' => 'typo3conf',
-                    'type' => DirectoryNode::class,
-                    'targetPermission' => $directoryPermission,
-                ],
                 $this->getFileadminStructure(),
             ];
 
@@ -189,6 +187,14 @@ class DefaultFactory
                 ];
             }
 
+            if (!Environment::isComposerMode()) {
+                $publicPathSubStructure[] = [
+                    'name' => 'typo3conf',
+                    'type' => DirectoryNode::class,
+                    'targetPermission' => $directoryPermission,
+                ];
+            }
+
             $structure = [
                 // Note that root node has no trailing slash like all others
                 'name' => Environment::getProjectPath(),
diff --git a/typo3/sysext/install/Classes/Report/InstallStatusReport.php b/typo3/sysext/install/Classes/Report/InstallStatusReport.php
index c44c3c263269..94117ce5ca20 100644
--- a/typo3/sysext/install/Classes/Report/InstallStatusReport.php
+++ b/typo3/sysext/install/Classes/Report/InstallStatusReport.php
@@ -91,7 +91,6 @@ final class InstallStatusReport implements StatusProviderInterface
             $varPath . '/transient/' => 2,
             $varPath . '/charset/' => 2,
             $varPath . '/lock/' => 2,
-            $sitePath . '/typo3conf/' => 2,
             Environment::getLabelsPath() => 0,
             $sitePath . '/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
             $sitePath . '/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
@@ -100,6 +99,8 @@ final class InstallStatusReport implements StatusProviderInterface
         // Check for writable extension folder files in non-composer mode only
         if (!Environment::isComposerMode()) {
             $checkWritable[Environment::getExtensionsPath()] = 0;
+            $checkWritable[$sitePath . '/typo3conf/'] = 2;
+
         }
 
         foreach ($checkWritable as $path => $requirementLevel) {
-- 
GitLab