Skip to content

Commit 93ea482

Browse files
committed
[BUGFIX] Ensure correct path calculation on system build
TYPO3 core `SystemEnvironmentBuilder` has been implement normal TYPO3 usages in mind respecting possible instance setup scenarios, to build low level system environment before taking configuration into account. Path calculations are based on different indicators, for example if TYPO3 is used in composer mode based on the PHP define() TYPO3_COMPOSER_MODE set during by the `typo3/cms-composer-installers` composer plugin during `composer install` actions. Per nature, PHP defines are immutable and cannot be changed anymore during runtime. As `typo3/testing-framework` is only installabe using composer the TYPO3_COMPOSER_MODE define is always set but is invalid for functional test instances build in legacy mode and making invalid path calculations. That was hidden quite some time now, and is related to a chain of changes over a very long period of time and finally popped up in early TYPO3 v13 development after introducing the configurable backend url feature. Functional tests building relative url for resources or links could run into the issue not retrieving the leading slash anymore due to path calculation errrors, leading to follup issues in `NormalizedParams` create method when using frontend requests. Eventually more developers run into that issue, but simply adjusted the test expectation instead analyzing the root of the curse and thus not reported it, which has been done recenently. To fix this issue changes on two fronts have to be made, in the TYPO3 core `SystemEnvironmentBuilder` [1] and in the testing-framework implementation. Note that only both changes together solves this issue, as the testing-framework change alone would not be executed due to using `self` for static method calls in the TYPO3 implementation. [1] https://review.typo3.org/c/Packages/TYPO3.CMS/+/86569 Resolves: #577 Releases: main, 8
1 parent fef0bd6 commit 93ea482

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Classes/Core/SystemEnvironmentBuilder.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,19 @@
4040
*/
4141
class SystemEnvironmentBuilder extends CoreSystemEnvironmentBuilder
4242
{
43+
private static ?bool $composerMode = null;
44+
4345
/**
4446
* @todo: Change default $requestType to 0 when dropping support for TYPO3 v12
4547
*/
46-
public static function run(int $entryPointLevel = 0, int $requestType = CoreSystemEnvironmentBuilder::REQUESTTYPE_FE, bool $composerMode = false)
48+
public static function run(int $entryPointLevel = 0, int $requestType = CoreSystemEnvironmentBuilder::REQUESTTYPE_FE, ?bool $composerMode = null): void
4749
{
48-
CoreSystemEnvironmentBuilder::run($entryPointLevel, $requestType);
50+
self::$composerMode = $composerMode;
51+
parent::run($entryPointLevel, $requestType);
4952
Environment::initialize(
5053
Environment::getContext(),
5154
Environment::isCli(),
52-
$composerMode,
55+
static::usesComposerClassLoading(),
5356
Environment::getProjectPath(),
5457
Environment::getPublicPath(),
5558
Environment::getVarPath(),
@@ -58,4 +61,16 @@ public static function run(int $entryPointLevel = 0, int $requestType = CoreSyst
5861
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
5962
);
6063
}
64+
65+
/**
66+
* Manage composer mode separated from TYPO3_COMPOSER_MODE define set by typo3/cms-composer-installers.
67+
*
68+
* Note that this will not with earlier TYPO3 versions than 13.4.
69+
* @link https://review.typo3.org/c/Packages/TYPO3.CMS/+/86569
70+
* @link https://github.com/TYPO3/testing-framework/issues/577
71+
*/
72+
protected static function usesComposerClassLoading(): bool
73+
{
74+
return self::$composerMode ?? parent::usesComposerClassLoading();
75+
}
6176
}

Classes/Core/Testbase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public function setUpBasicTypo3Bootstrap($instancePath): ContainerInterface
745745
$classLoader = require $this->getPackagesPath() . '/autoload.php';
746746
// @todo: Remove else branch when dropping support for v12
747747
if ($hasConsolidatedHttpEntryPoint) {
748-
SystemEnvironmentBuilder::run(0, SystemEnvironmentBuilder::REQUESTTYPE_CLI);
748+
SystemEnvironmentBuilder::run(0, SystemEnvironmentBuilder::REQUESTTYPE_CLI, false);
749749
} else {
750750
SystemEnvironmentBuilder::run(1, SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI);
751751
}

0 commit comments

Comments
 (0)