Skip to content

Commit d266e3d

Browse files
authored
[TASK] Use /index.php as application entry point (#533)
/typo3/index.php is deprecated and must not longer be used as of https://review.typo3.org/c/Packages/TYPO3.CMS/+/74366 Releases: main Resolves: https://forge.typo3.org/issues/87889
1 parent ba5af3f commit d266e3d

File tree

5 files changed

+87
-42
lines changed

5 files changed

+87
-42
lines changed

Classes/Core/Acceptance/Helper/Login.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Login extends Module
3939
];
4040

4141
/**
42-
* Set a backend user session cookie and load the backend index.php.
42+
* Set a backend user session cookie and load the backend entrypoint.
4343
*
4444
* Use this action to change the backend user and avoid switching between users in the backend module
4545
* "Backend Users" as this will change the user session ID and make it useless for subsequent calls of this action.
@@ -55,21 +55,21 @@ public function useExistingSession(string $role, float|int $waitTime = 0.5)
5555

5656
$hasSession = $this->_loadSession();
5757
if ($hasSession && $newUserSessionId !== '' && $newUserSessionId !== $this->getUserSessionId()) {
58-
$webDriver->amOnPage('/typo3/index.php');
58+
$webDriver->amOnPage('/typo3');
5959
$webDriver->wait($waitTime);
6060
$this->_deleteSession();
6161
$hasSession = false;
6262
}
6363

6464
if (!$hasSession) {
65-
$webDriver->amOnPage('/typo3/index.php');
65+
$webDriver->amOnPage('/typo3');
6666
$webDriver->wait($waitTime);
6767
$webDriver->waitForElement('body[data-typo3-login-ready]');
6868
$this->_createSession($newUserSessionId);
6969
}
7070

7171
// Reload the page to have a logged in backend.
72-
$webDriver->amOnPage('/typo3/index.php');
72+
$webDriver->amOnPage('/typo3');
7373
$webDriver->wait($waitTime);
7474

7575
// Ensure main content frame is fully loaded, otherwise there are load-race-conditions ..

Classes/Core/Functional/FunctionalTestCase.php

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use TYPO3\CMS\Core\Core\Environment;
3131
use TYPO3\CMS\Core\Database\Connection;
3232
use TYPO3\CMS\Core\Database\ConnectionPool;
33+
use TYPO3\CMS\Core\Http\Application as CoreHttpApplication;
3334
use TYPO3\CMS\Core\Http\NormalizedParams;
3435
use TYPO3\CMS\Core\Http\ServerRequest;
3536
use TYPO3\CMS\Core\Http\Stream;
@@ -496,15 +497,20 @@ private function createServerRequest(string $url, string $method = 'GET'): Serve
496497
{
497498
$requestUrlParts = parse_url($url);
498499
$docRoot = $this->instancePath;
500+
501+
// @todo: Remove when dropping support for v12
502+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
503+
$scriptPrefix = $hasConsolidatedHttpEntryPoint ? '' : '/typo3';
504+
499505
$serverParams = [
500506
'DOCUMENT_ROOT' => $docRoot,
501507
'HTTP_USER_AGENT' => 'TYPO3 Functional Test Request',
502508
'HTTP_HOST' => $requestUrlParts['host'] ?? 'localhost',
503509
'SERVER_NAME' => $requestUrlParts['host'] ?? 'localhost',
504510
'SERVER_ADDR' => '127.0.0.1',
505511
'REMOTE_ADDR' => '127.0.0.1',
506-
'SCRIPT_NAME' => '/typo3/index.php',
507-
'PHP_SELF' => '/typo3/index.php',
512+
'SCRIPT_NAME' => $scriptPrefix . '/index.php',
513+
'PHP_SELF' => $scriptPrefix . '/index.php',
508514
'SCRIPT_FILENAME' => $docRoot . '/index.php',
509515
'PATH_TRANSLATED' => $docRoot . '/index.php',
510516
'QUERY_STRING' => $requestUrlParts['query'] ?? '',
@@ -944,19 +950,23 @@ private function retrieveFrontendSubRequestResult(
944950
FrameworkState::push();
945951
FrameworkState::reset();
946952

947-
// Re-init Environment $currentScript: Entry point to FE calls is /index.php, not /typo3/index.php
948-
// see also \TYPO3\TestingFramework\Core\SystemEnvironmentBuilder
949-
Environment::initialize(
950-
Environment::getContext(),
951-
Environment::isCli(),
952-
false,
953-
Environment::getProjectPath(),
954-
Environment::getPublicPath(),
955-
Environment::getVarPath(),
956-
Environment::getConfigPath(),
957-
Environment::getPublicPath() . '/index.php',
958-
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
959-
);
953+
// @todo: Remove when dropping support for v12
954+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
955+
if (!$hasConsolidatedHttpEntryPoint) {
956+
// Re-init Environment $currentScript: Entry point to FE calls is /index.php, not /typo3/index.php
957+
// see also \TYPO3\TestingFramework\Core\SystemEnvironmentBuilder
958+
Environment::initialize(
959+
Environment::getContext(),
960+
Environment::isCli(),
961+
false,
962+
Environment::getProjectPath(),
963+
Environment::getPublicPath(),
964+
Environment::getVarPath(),
965+
Environment::getConfigPath(),
966+
Environment::getPublicPath() . '/index.php',
967+
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
968+
);
969+
}
960970

961971
// Needed for GeneralUtility::getIndpEnv('SCRIPT_NAME') to return correct value
962972
// instead of 'vendor/phpunit/phpunit/phpunit', used eg. in TypoScriptFrontendController absRefPrefix='auto'
@@ -1023,19 +1033,22 @@ private function retrieveFrontendSubRequestResult(
10231033

10241034
FrameworkState::pop();
10251035

1026-
// Reset Environment $currentScript: Entry point is /typo3/index.php again.
1027-
// see also \TYPO3\TestingFramework\Core\SystemEnvironmentBuilder
1028-
Environment::initialize(
1029-
Environment::getContext(),
1030-
Environment::isCli(),
1031-
false,
1032-
Environment::getProjectPath(),
1033-
Environment::getPublicPath(),
1034-
Environment::getVarPath(),
1035-
Environment::getConfigPath(),
1036-
Environment::getPublicPath() . '/typo3/index.php',
1037-
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1038-
);
1036+
// @todo: Remove when dropping support for v12
1037+
if (!$hasConsolidatedHttpEntryPoint) {
1038+
// Reset Environment $currentScript: Entry point is /typo3/index.php again.
1039+
// see also \TYPO3\TestingFramework\Core\SystemEnvironmentBuilder
1040+
Environment::initialize(
1041+
Environment::getContext(),
1042+
Environment::isCli(),
1043+
false,
1044+
Environment::getProjectPath(),
1045+
Environment::getPublicPath(),
1046+
Environment::getVarPath(),
1047+
Environment::getConfigPath(),
1048+
Environment::getPublicPath() . '/typo3/index.php',
1049+
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1050+
);
1051+
}
10391052
}
10401053
return $response;
10411054
}

Classes/Core/SystemEnvironmentBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
*/
4141
class SystemEnvironmentBuilder extends CoreSystemEnvironmentBuilder
4242
{
43+
/**
44+
* @todo: Change default $requestType to 0 when dropping support for TYPO3 v12
45+
*/
4346
public static function run(int $entryPointLevel = 0, int $requestType = CoreSystemEnvironmentBuilder::REQUESTTYPE_FE, bool $composerMode = false)
4447
{
4548
CoreSystemEnvironmentBuilder::run($entryPointLevel, $requestType);

Classes/Core/Testbase.php

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use TYPO3\CMS\Core\Database\ConnectionPool;
3535
use TYPO3\CMS\Core\Database\Schema\SchemaMigrator;
3636
use TYPO3\CMS\Core\Database\Schema\SqlReader;
37+
use TYPO3\CMS\Core\Http\Application as CoreHttpApplication;
3738
use TYPO3\CMS\Core\Package\PackageManager;
3839
use TYPO3\CMS\Core\Service\DependencyOrderingService;
3940
use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -75,7 +76,11 @@ public function __construct()
7576
*/
7677
public function defineSitePath(): void
7778
{
78-
$_SERVER['SCRIPT_NAME'] = $this->getWebRoot() . 'typo3/index.php';
79+
// @todo: Remove when dropping support for v12
80+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
81+
$scriptPrefix = $hasConsolidatedHttpEntryPoint ? '' : 'typo3/';
82+
83+
$_SERVER['SCRIPT_NAME'] = $this->getWebRoot() . $scriptPrefix . 'index.php';
7984
if (!file_exists($_SERVER['SCRIPT_NAME'])) {
8085
$this->exitWithMessage('Unable to determine path to entry script. Please check your path or set an environment variable \'TYPO3_PATH_ROOT\' to your root path.');
8186
}
@@ -229,11 +234,20 @@ public function setUpInstanceCoreLinks(
229234
// We can't just link the entry scripts here, because acceptance tests will make use of them
230235
// and we need Composer Mode to be turned off, thus they need to be rewritten to use the SystemEnvironmentBuilder
231236
// of the testing framework.
232-
$entryPointsToSet = [
233-
$instancePath . '/typo3/sysext/backend/Resources/Private/Php/backend.php' => $instancePath . '/typo3/index.php',
234-
$instancePath . '/typo3/sysext/frontend/Resources/Private/Php/frontend.php' => $instancePath . '/index.php',
235-
$instancePath . '/typo3/sysext/install/Resources/Private/Php/install.php' => $instancePath . '/typo3/install.php',
236-
];
237+
// @todo: Remove else branch when dropping support for v12
238+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
239+
if ($hasConsolidatedHttpEntryPoint) {
240+
$entryPointsToSet = [
241+
$instancePath . '/typo3/sysext/core/Resources/Private/Php/index.php' => $instancePath . '/index.php',
242+
$instancePath . '/typo3/sysext/install/Resources/Private/Php/install.php' => $instancePath . '/typo3/install.php',
243+
];
244+
} else {
245+
$entryPointsToSet = [
246+
$instancePath . '/typo3/sysext/backend/Resources/Private/Php/backend.php' => $instancePath . '/typo3/index.php',
247+
$instancePath . '/typo3/sysext/frontend/Resources/Private/Php/frontend.php' => $instancePath . '/index.php',
248+
$instancePath . '/typo3/sysext/install/Resources/Private/Php/install.php' => $instancePath . '/typo3/install.php',
249+
];
250+
}
237251
$autoloadFile = dirname(__DIR__, 4) . '/autoload.php';
238252

239253
foreach ($entryPointsToSet as $source => $target) {
@@ -715,13 +729,21 @@ public function setUpTestDatabase(string $databaseName, string $originalDatabase
715729
public function setUpBasicTypo3Bootstrap($instancePath): ContainerInterface
716730
{
717731
$_SERVER['PWD'] = $instancePath;
718-
$_SERVER['argv'][0] = 'typo3/index.php';
732+
// @todo: Remove when dropping support for v12
733+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
734+
$scriptPrefix = $hasConsolidatedHttpEntryPoint ? '' : 'typo3/';
735+
$_SERVER['argv'][0] = $scriptPrefix . 'index.php';
719736

720737
// Reset state from a possible previous run
721738
GeneralUtility::purgeInstances();
722739

723740
$classLoader = require $this->getPackagesPath() . '/autoload.php';
724-
SystemEnvironmentBuilder::run(1, SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI);
741+
// @todo: Remove else branch when dropping support for v12
742+
if ($hasConsolidatedHttpEntryPoint) {
743+
SystemEnvironmentBuilder::run(0, SystemEnvironmentBuilder::REQUESTTYPE_CLI);
744+
} else {
745+
SystemEnvironmentBuilder::run(1, SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI);
746+
}
725747
$container = Bootstrap::init($classLoader);
726748
// Make sure output is not buffered, so command-line output can take place and
727749
// phpunit does not whine about changed output bufferings in tests.

Resources/Core/Build/UnitTestsBootstrap.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@
4848
// We can use the "typo3/cms-composer-installers" constant "TYPO3_COMPOSER_MODE" to determine composer mode.
4949
// This should be always true except for TYPO3 mono repository.
5050
$composerMode = defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE === true;
51-
$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
52-
\TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, $requestType, $composerMode);
51+
52+
// @todo: Remove else branch when dropping support for v12
53+
$hasConsolidatedHttpEntryPoint = class_exists(CoreHttpApplication::class);
54+
if ($hasConsolidatedHttpEntryPoint) {
55+
\TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI, $composerMode);
56+
} else {
57+
$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
58+
\TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, $requestType, $composerMode);
59+
}
5360

5461
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext');
5562
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets');

0 commit comments

Comments
 (0)