protected $bootstrap;
/**
- *
- * @var string
+ * Number of subdirectories where the entry script is located, relative to PATH_site
+ * @var int
*/
- protected $entryPointPath = 'typo3/';
+ protected $entryPointLevel = 1;
/**
* All available request handlers that can deal with a CLI Request
$this->bootstrap = Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_CLI)
- ->baseSetup($this->entryPointPath);
+ ->baseSetup($this->entryPointLevel);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
protected $bootstrap;
/**
- * @var string
+ * Number of subdirectories where the entry script is located, relative to PATH_site
+ * Usually this is equal to PATH_site = 0
+ * @var int
*/
- protected $entryPointPath = 'typo3/';
+ protected $entryPointLevel = 1;
/**
* @var \Psr\Http\Message\ServerRequestInterface
$this->bootstrap = Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_BE | (!empty($_GET['ajaxID']) ? TYPO3_REQUESTTYPE_AJAX : 0))
- ->baseSetup($this->entryPointPath);
+ ->baseSetup($this->entryPointLevel);
// Redirect to install tool if base configuration is not found
if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
- $this->bootstrap->redirectToInstallTool($this->entryPointPath);
+ $this->bootstrap->redirectToInstallTool($this->entryPointLevel);
}
foreach ($this->availableRequestHandlers as $requestHandler) {
protected $bootstrap;
/**
- * @var string
+ * Number of subdirectories where the entry script is located, relative to PATH_site
+ * @var int
*/
- protected $entryPointPath = 'typo3/sysext/core/bin/';
+ protected $entryPointLevel = 4;
/**
* All available request handlers that can deal with a CLI Request
$this->bootstrap = Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_CLI)
- ->baseSetup($this->entryPointPath);
+ ->baseSetup($this->entryPointLevel);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
*
* Script execution will be aborted if something fails here.
*
- * @param string $relativePathPart Relative path of entry script back to document root
+ * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
* @return Bootstrap
* @throws \RuntimeException when TYPO3_REQUESTTYPE was not set before, setRequestType() needs to be called before
* @internal This is not a public API method, do not use in own extensions
*/
- public function baseSetup($relativePathPart = '')
+ public function baseSetup($entryPointLevel = 0)
{
if (!defined('TYPO3_REQUESTTYPE')) {
throw new \RuntimeException('No Request Type was set, TYPO3 does not know in which context it is run.', 1450561838);
}
- SystemEnvironmentBuilder::run($relativePathPart);
+ SystemEnvironmentBuilder::run($entryPointLevel);
if (!self::$usesComposerClassLoading && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
ClassLoadingInformation::registerClassLoadingInformation();
}
/**
* Redirect to install tool if LocalConfiguration.php is missing.
*
+ * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
* @internal This is not a public API method, do not use in own extensions
*/
- public function redirectToInstallTool($relativePathPart = '')
+ public function redirectToInstallTool($entryPointLevel = 0)
{
- $backPathToSiteRoot = str_repeat('../', count(explode('/', $relativePathPart)) - 1);
- header('Location: ' . $backPathToSiteRoot . 'typo3/sysext/install/Start/Install.php');
+ $path = TYPO3_mainDir . 'sysext/install/Start/Install.php';
+ if ($entryPointLevel > 0) {
+ $path = str_repeat('../', $entryPointLevel) . $path;
+ }
+ header('Location: ' . $path);
die;
}
* This entry method is used in all scopes (FE, BE, eid, ajax, ...)
*
* @internal This method should not be used by 3rd party code. It will change without further notice.
- * @param string $relativePathPart Relative path of the entry script back to document root
+ * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
* @return void
*/
- public static function run($relativePathPart = '')
+ public static function run($entryPointLevel = 0)
{
self::defineBaseConstants();
- self::definePaths($relativePathPart);
+ self::definePaths($entryPointLevel);
self::checkMainPathsExist();
self::initializeGlobalVariables();
self::initializeGlobalTimeTrackingVariables();
/**
* Calculate all required base paths and set as constants.
*
- * @param string $relativePathPart Relative path of the entry script back to document root
+ * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
* @return void
*/
- protected static function definePaths($relativePathPart = '')
+ protected static function definePaths($entryPointLevel = 0)
{
// Relative path from document root to typo3/ directory
// Hardcoded to "typo3/"
// Absolute path of the document root of the instance with trailing slash
// Example "/var/www/instance-name/htdocs/"
if (!defined('PATH_site')) {
- define('PATH_site', self::getPathSite($relativePathPart));
+ define('PATH_site', self::getPathSite($entryPointLevel));
}
// Absolute path of the typo3 directory of the instance with trailing slash
// Example "/var/www/instance-name/htdocs/typo3/"
}
/**
- * Calculate the document root part to the instance from PATH_thisScript
+ * Calculate the document root part to the instance from PATH_thisScript.
+ * This is based on the amount of subdirectories "under" PATH_site where PATH_thisScript is located.
*
- * We have two main scenarios for entry points:
- * - Directly called documentRoot/index.php (-> FE call or eiD include): index.php sets $relativePathPart to
- * empty string to hint this code that the document root is identical to the directory the script is located at.
- * - An indirect include of any Backend related script (-> typo3/index.php or the install tool).
- * - A Backend script: This is the case for the index.php dispatcher and other entry scripts like 'cli_dispatch.phpsh'
- * or 'typo3/index.php' that are located inside typo3/ directly. In this case the Bootstrap->run() command sets
- * 'typo3/' as $relativePathPart as base to calculate the document root.
+ * The following main scenarios for entry points exist by default in the TYPO3 core:
+ * - Directly called documentRoot/index.php (-> FE call or eiD include): index.php is located in the same directory
+ * as the main project. The document root is identical to the directory the script is located at.
+ * - The install tool, located under typo3/sysext/install/Start/Install.php.
+ * - A Backend script: This is the case for the typo3/index.php dispatcher and other entry scripts like 'cli_dispatch.phpsh'
+ * or 'typo3/index.php' that are located inside typo3/ directly.
*
- * @param string $relativePathPart Relative directory part from document root to script path
+ * @param int $entryPointLevel Number of subdirectories where the entry script is located under the document root
* @return string Absolute path to document root of installation
*/
- protected static function getPathSite($relativePathPart)
+ protected static function getPathSite($entryPointLevel)
{
- $entryScriptDirectory = self::getUnifiedDirectoryNameWithTrailingSlash(PATH_thisScript);
- if ($relativePathPart !== '') {
- $pathSite = substr($entryScriptDirectory, 0, -strlen($relativePathPart));
+ $entryScriptDirectory = self::getUnifiedDirectoryName(PATH_thisScript);
+ if ($entryPointLevel > 0) {
+ list($pathSite) = GeneralUtility::revExplode('/', $entryScriptDirectory, $entryPointLevel+1);
} else {
$pathSite = $entryScriptDirectory;
}
- return $pathSite;
+ return $pathSite . '/';
}
/**
* Remove file name from script path and unify for Windows and Unix
*
* @param string $absolutePath Absolute path to script
- * @return string Directory name of script file location, unified for Windows and Unix
+ * @return string Directory name of script file location, unified for Windows and Unix without the trailing slash
*/
- protected static function getUnifiedDirectoryNameWithTrailingSlash($absolutePath)
+ protected static function getUnifiedDirectoryName($absolutePath)
{
$directory = dirname($absolutePath);
if (TYPO3_OS === 'WIN') {
$directory = str_replace('\\', '/', $directory);
}
- return $directory . '/';
+ return $directory;
}
/**
--- /dev/null
+==========================================================================
+Breaking: #75323 - Removed parameter entryPointPath from main applications
+==========================================================================
+
+Description
+===========
+
+The entry point ``PHP`` classes for ``index.php``, ``typo3/index.php`` and so for forth (called "Application classes")
+now have a parameter not to define the path to the entry point but the number of subdirectories under the main
+installation path, allowing to not specify the name of the path, but just the levels of subdirectories.
+
+Subsequently, the methods ``Bootstrap->baseSetup()``, ``Bootstrap->redirectToInstallTool()`` and
+``SystemEnvironmentBuilder::run()`` now expect an integer as parameter, instead of the path to the entry point script.
+
+
+Impact
+======
+
+Calling one of the methods above with a string as parameter instead of an integer the calculation for PATH_site
+which is the base for the whole installation will fail.
+
+
+Affected Installations
+======================
+
+Any installation with custom entry points or custom extensions with separate entry points.
+
+
+Migration
+=========
+
+Use the entry point level as integer, instead of the string, in your custom entry points. See
+``TYPO3\CMS\Backend\Http\Application`` for an example.
Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_CLI)
- ->baseSetup('')
+ ->baseSetup()
->loadConfigurationAndInitialize(true)
->loadTypo3LoadedExtAndExtLocalconf(true)
->setFinalCachingFrameworkCacheConfiguration()
/**
* @test
*/
- public function getUnifiedDirectoryNameWithTrailingSlashReturnsCorrectPathOnUnix()
+ public function getUnifiedDirectoryNameReturnsCorrectPathOnUnix()
{
if (TYPO3_OS === 'WIN') {
$this->markTestSkipped('Test not available on Windows OS.');
}
$input = '/foo/bar/test.php';
- $expected = '/foo/bar/';
- $actual = $this->subject->_call('getUnifiedDirectoryNameWithTrailingSlash', $input);
+ $expected = '/foo/bar';
+ $actual = $this->subject->_call('getUnifiedDirectoryName', $input);
$this->assertEquals($expected, $actual);
}
protected $bootstrap;
/**
- * Usually this is equal to PATH_site = kept empty
- * @var string
+ * Number of subdirectories where the entry script is located, relative to PATH_site
+ * Usually this is equal to PATH_site = 0
+ * @var int
*/
- protected $entryPointPath = '';
+ protected $entryPointLevel = 0;
/**
* All available request handlers that can deal with a Frontend Request
$this->bootstrap = Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_FE)
- ->baseSetup($this->entryPointPath);
+ ->baseSetup($this->entryPointLevel);
// Redirect to install tool if base configuration is not found
if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
- $this->bootstrap->redirectToInstallTool($this->entryPointPath);
+ $this->bootstrap->redirectToInstallTool($this->entryPointLevel);
}
foreach ($this->availableRequestHandlers as $requestHandler) {
protected $bootstrap;
/**
- * @var string
+ * Number of subdirectories where the entry script is located, relative to PATH_site
+ * @var int
*/
- protected $entryPointPath = 'typo3/sysext/install/Start/';
+ protected $entryPointLevel = 4;
/**
* All available request handlers that can handle an install tool request
$this->bootstrap = Bootstrap::getInstance()
->initializeClassLoader($classLoader)
->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_INSTALL)
- ->baseSetup($this->entryPointPath);
+ ->baseSetup($this->entryPointLevel);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);