[FEATURE] Introduce "Application" classes for all entry points 93/40493/14
authorBenjamin Mack <benni@typo3.org>
Sat, 20 Jun 2015 16:26:25 +0000 (18:26 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 30 Jun 2015 21:47:28 +0000 (23:47 +0200)
In an effort to move away from TYPO3_MODE and global code
an instance that acts as an entry point has been introduced. The
Application class which serves as a wrapper for setting up the
Bootstrap and calling the request has been introduced.

Additionally, new Applications (like typo3_console) can benefit
from the flexible way of registering RequestHandlers on their own
while still using the bootstrap or only parts of it.

Resolves: #67808
Releases: master
Change-Id: I20c92d0bc8df5d50d76922a8dfe1cbd898e6f1dd
Reviewed-on: http://review.typo3.org/40493
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
47 files changed:
composer.json
index.php
typo3/ajax.php
typo3/alt_clickmenu.php
typo3/alt_db_navframe.php
typo3/alt_doc.php
typo3/alt_file_navframe.php
typo3/backend.php
typo3/browser.php
typo3/cli_dispatch.phpsh
typo3/db_new.php
typo3/dummy.php
typo3/index.php
typo3/init.php
typo3/login_frameset.php
typo3/logout.php
typo3/mod.php
typo3/move_el.php
typo3/show_item.php
typo3/sysext/backend/Classes/AjaxRequestHandler.php [deleted file]
typo3/sysext/backend/Classes/BackendModuleRequestHandler.php [deleted file]
typo3/sysext/backend/Classes/CliRequestHandler.php [deleted file]
typo3/sysext/backend/Classes/Console/Application.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Console/CliRequestHandler.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Http/Application.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Http/RequestHandler.php [new file with mode: 0644]
typo3/sysext/backend/Classes/RequestHandler.php [deleted file]
typo3/sysext/backend/Tests/Unit/BackendModuleRequestHandlerTest.php
typo3/sysext/core/Build/UnitTestsBootstrap.php
typo3/sysext/core/Classes/Core/ApplicationInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Documentation/Changelog/master/Feature-67808-IntroduceApplicationClassesForEntryPointsAndEquivalentRequestHandlers.rst [new file with mode: 0644]
typo3/sysext/core/Tests/FunctionalTestCaseBootstrapUtility.php
typo3/sysext/frontend/Classes/EidRequestHandler.php [deleted file]
typo3/sysext/frontend/Classes/Http/Application.php [new file with mode: 0644]
typo3/sysext/frontend/Classes/Http/EidRequestHandler.php [new file with mode: 0644]
typo3/sysext/frontend/Classes/Http/RequestHandler.php [new file with mode: 0644]
typo3/sysext/frontend/Classes/RequestHandler.php [deleted file]
typo3/sysext/install/Classes/Http/Application.php [new file with mode: 0644]
typo3/sysext/install/Classes/Http/RequestHandler.php [new file with mode: 0644]
typo3/sysext/install/Classes/RequestHandler.php [deleted file]
typo3/sysext/install/Start/Install.php
typo3/tce_db.php
typo3/tce_file.php
typo3/thumbs.php

index a274671..1b320e4 100644 (file)
@@ -40,8 +40,8 @@
                "symfony/console": "2.5.11",
                "symfony/finder": "2.6.9",
                "doctrine/instantiator": "1.0.4",
-               "helhum/class-alias-loader": "1.1.5",
-               "typo3/cms-composer-installers": "1.1.4"
+               "helhum/class-alias-loader": "1.1.8",
+               "typo3/cms-composer-installers": "1.2.0"
        },
        "require-dev": {
                "mikey179/vfsStream": "1.4.*@dev",
index e24c525..c625c8d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -27,7 +27,8 @@ if (version_compare(PHP_VERSION, '5.5.0', '<')) {
        die('TYPO3 CMS requires PHP 5.5 or above');
 }
 
-define('TYPO3_MODE', 'FE');
-
-require __DIR__ . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run()->shutdown();
+// Set up the application for the Frontend
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/typo3/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
+});
index fbe1263..da75086 100644 (file)
@@ -18,8 +18,7 @@
  * handled by TYPO3\CMS\Backend\AjaxRequestHandler and AjaxController.
  * See $TYPO3_CONF_VARS['BE']['AJAX'] and the Core APIs on how to register an AJAX call in the TYPO3 Backend.
  */
-$TYPO3_AJAX = TRUE;
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/')->shutdown();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
+});
index 6944adf..ac6957c 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('alt_clickmenu.php is deprecated as of TYPO3 CMS 7, and will not work anymore, please use the ajax.php functionality.');
-$clickMenuController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\ClickMenuController::class);
-$clickMenuController->main();
-$clickMenuController->printContent();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('alt_clickmenu.php is deprecated as of TYPO3 CMS 7, and will not work anymore, please use the ajax.php functionality.');
+               $clickMenuController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\ClickMenuController::class);
+               $clickMenuController->main();
+               $clickMenuController->printContent();
+       });
+});
index bdf918a..b37bf55 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of alt_db_navframe.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8');
-// Make instance if it is not an AJAX call
-if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
-       $pageTreeNavigationController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\PageTreeNavigationController::class);
-       $pageTreeNavigationController->initPage();
-       $pageTreeNavigationController->main();
-       $pageTreeNavigationController->printContent();
-}
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of alt_db_navframe.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8');
+               // Make instance if it is not an AJAX call
+               if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
+                       $pageTreeNavigationController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\PageTreeNavigationController::class);
+                       $pageTreeNavigationController->initPage();
+                       $pageTreeNavigationController->main();
+                       $pageTreeNavigationController->printContent();
+               }
+       });
+});
index cab75fd..23b520d 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Backend\Utility\BackendUtility::lockRecords();
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-\TYPO3\CMS\Backend\Utility\BackendUtility::lockRecords();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to FormEngine was moved to an own module. Please use BackendUtility::getModuleUrl(\'record_edit\') to link to alt_doc.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to FormEngine was moved to an own module. Please use BackendUtility::getModuleUrl(\'record_edit\') to link to alt_doc.php. This script will be removed in TYPO3 CMS 8.'
-);
+               /* @var $editDocumentController \TYPO3\CMS\Backend\Controller\EditDocumentController */
+               $editDocumentController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\EditDocumentController::class);
 
-/* @var $editDocumentController \TYPO3\CMS\Backend\Controller\EditDocumentController */
-$editDocumentController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\EditDocumentController::class);
+               // Preprocessing, storing data if submitted to
+               $editDocumentController->preInit();
 
-// Preprocessing, storing data if submitted to
-$editDocumentController->preInit();
+               // Checks, if a save button has been clicked (or the doSave variable is sent)
+               if ($editDocumentController->doProcessData()) {
+                       $formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
+                       if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'editRecord')) {
+                               $editDocumentController->processData();
+                       }
+               }
 
-// Checks, if a save button has been clicked (or the doSave variable is sent)
-if ($editDocumentController->doProcessData()) {
-       $formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
-       if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'editRecord')) {
-               $editDocumentController->processData();
-       }
-}
-
-$editDocumentController->init();
-$editDocumentController->main();
-$editDocumentController->printContent();
+               $editDocumentController->init();
+               $editDocumentController->main();
+               $editDocumentController->printContent();
+       });
+});
index 5c14d76..1eb1dd0 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of alt_file_navframe.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8');
 
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of alt_file_navframe.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8');
-
-// Make instance if it is not an AJAX call
-if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
-       $fileSystemNavigationFrameController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController::class);
-       $fileSystemNavigationFrameController->initPage();
-       $fileSystemNavigationFrameController->main();
-       $fileSystemNavigationFrameController->printContent();
-}
+               // Make instance if it is not an AJAX call
+               if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
+                       $fileSystemNavigationFrameController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController::class);
+                       $fileSystemNavigationFrameController->initPage();
+                       $fileSystemNavigationFrameController->main();
+                       $fileSystemNavigationFrameController->printContent();
+               }
+       });
+});
index 66c23f1..8c6ef22 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
-
-// Document generation
-$TYPO3backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\BackendController::class);
-$TYPO3backend->render();
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->shutdown();
+               // Document generation
+               $GLOBALS['TYPO3backend'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\BackendController::class);
+               $GLOBALS['TYPO3backend']->render();
+       });
+});
index d31458c..8cb9ccd 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to the file/record browser window was moved to an own module. Please use BackendUtility::getModuleUrl(\'browser\') to link to browser.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to the file/record browser window was moved to an own module. Please use BackendUtility::getModuleUrl(\'browser\') to link to browser.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$elementBrowserFramesetController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Controller\ElementBrowserFramesetController::class);
-$elementBrowserFramesetController->main();
-$elementBrowserFramesetController->printContent();
+               $elementBrowserFramesetController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Controller\ElementBrowserFramesetController::class);
+               $elementBrowserFramesetController->main();
+               $elementBrowserFramesetController->printContent();
+       });
+});
index 1bc8ed2..e206192 100755 (executable)
  *
  * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
-define('TYPO3_cliMode', TRUE);
-
-require __DIR__ . '/sysext/core/Classes/Core/CliBootstrap.php';
-\TYPO3\CMS\Core\Core\CliBootstrap::checkEnvironmentOrDie();
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/')->shutdown();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Console\Application($classLoader))->run();
+});
index faebdee..fb92b70 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to create a new database entry was moved to an own module. Please use BackendUtility::getModuleUrl(\'db_new\') to link to db_new.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to create a new database entry was moved to an own module. Please use BackendUtility::getModuleUrl(\'db_new\') to link to db_new.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class);
-$newRecordController->main();
-$newRecordController->printContent();
+               $newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class);
+               $newRecordController->main();
+               $newRecordController->printContent();
+       });
+});
index 4275d13..f041bfb 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to the dummy window was moved to an own module. Please use BackendUtility::getModuleUrl(\'dummy\') to link to dummy.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to the dummy window was moved to an own module. Please use BackendUtility::getModuleUrl(\'dummy\') to link to dummy.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$dummyController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\DummyController::class);
-$dummyController->main();
-$dummyController->printContent();
+               $dummyController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\DummyController::class);
+               $dummyController->main();
+               $dummyController->printContent();
+       });
+});
index d31f369..3871198 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_PROCEED_IF_NO_USER', 1);
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-$loginController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LoginController::class);
-$loginController->main();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               // currently implemented as a closure as there is no Request/Response implementation or routing in the backend
+               $loginController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LoginController::class);
+               $loginController->main();
+       });
+});
index 4f18342..148f02d 100644 (file)
@@ -40,8 +40,9 @@
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of typo3/init.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8. Initialize the bootstrap call directly in your entry script.');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Usage of typo3/init.php is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8. Initialize the bootstrap call directly in your entry script.');
+       });
+});
index 7873c52..ef3e581 100644 (file)
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 define('TYPO3_PROCEED_IF_NO_USER', 1);
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'Login frameset is moved to an own module. Please use BackendUtility::getModuleUrl(\'login_frameset\') to link to login_frameset.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'Login frameset is moved to an own module. Please use BackendUtility::getModuleUrl(\'login_frameset\') to link to login_frameset.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-// Make instance:
-$loginFramesetController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LoginFramesetController::class);
-$loginFramesetController->main();
-$loginFramesetController->printContent();
+               // Make instance:
+               $loginFramesetController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LoginFramesetController::class);
+               $loginFramesetController->main();
+               $loginFramesetController->printContent();
+       });
+});
index 3b54af7..4c09682 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to logout was moved to an own module. Please use BackendUtility::getModuleUrl(\'logout\') to link to logout.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to logout was moved to an own module. Please use BackendUtility::getModuleUrl(\'logout\') to link to logout.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$logoutController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LogoutController::class);
-$logoutController->logout();
+               $logoutController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\LogoutController::class);
+               $logoutController->logout();
+       });
+});
index b5b99db..48894b3 100644 (file)
@@ -19,6 +19,7 @@ namespace TYPO3\CMS\Backend;
  * Main entry point for all modules (wizards, backend modules, module functions etc)
  * which usually uses the BackendModuleRequestHandler
  */
-define('TYPO3_MODE', 'BE');
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/')->shutdown();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
+});
index 23cdbbb..ea1e729 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'Moving an element is moved to an own module. Please use BackendUtility::getModuleUrl(\'move_element\') to link to move_el.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'Moving an element is moved to an own module. Please use BackendUtility::getModuleUrl(\'move_element\') to link to move_el.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$moveElementController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\ContentElement\MoveElementController::class);
-$moveElementController->main();
-$moveElementController->printContent();
+               $moveElementController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\ContentElement\MoveElementController::class);
+               $moveElementController->main();
+               $moveElementController->printContent();
+       });
+});
index f80a4d7..ab6ff69 100644 (file)
  * The TYPO3 project - inspiring people to share!
  */
 
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to show_item was moved to an own module. Please use BackendUtility::getModuleUrl(\'show_item\') to link to show_item.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to show_item was moved to an own module. Please use BackendUtility::getModuleUrl(\'show_item\') to link to show_item.php. This script will be removed in TYPO3 CMS 8.'
-);
-
-$elementInformationController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
-       \TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController::class
-);
-$elementInformationController->main();
-$elementInformationController->printContent();
+               $elementInformationController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                       \TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController::class
+               );
+               $elementInformationController->main();
+               $elementInformationController->printContent();
+       });
+});
diff --git a/typo3/sysext/backend/Classes/AjaxRequestHandler.php b/typo3/sysext/backend/Classes/AjaxRequestHandler.php
deleted file mode 100644 (file)
index 814b85d..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Base class for all AJAX-related calls for the TYPO3 Backend run through typo3/ajax.php.
- * Before doing the basic BE-related set up of this request (see the additional calls on $this->bootstrap inside
- * handleRequest()), some AJAX-calls can be made without a valid user, which is determined here.
- *
- * Due to legacy reasons, the actual logic is in EXT:core/Http/AjaxRequestHandler which will eventually
- * be moved into this class.
- * In the future, the logic for "TYPO3_PROCEED_IF_NO_USER" will be moved in here as well.
- */
-class AjaxRequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * List of requests that don't need a valid BE user
-        * @var array
-        */
-       protected $publicAjaxIds = array(
-               'BackendLogin::login',
-               'BackendLogin::logout',
-               'BackendLogin::refreshLogin',
-               'BackendLogin::isTimedOut',
-               'BackendLogin::getChallenge',
-               'BackendLogin::getRsaPublicKey'
-       );
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles any AJAX request in the TYPO3 Backend
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               // First get the ajaxID
-               $ajaxID = isset($_POST['ajaxID']) ? $_POST['ajaxID'] : $_GET['ajaxID'];
-               if (isset($ajaxID)) {
-                       $ajaxID = (string)stripslashes($ajaxID);
-               }
-
-               $GLOBALS['ajaxID'] = $ajaxID;
-               $this->boot($ajaxID);
-
-               // Finding the script path from the registry
-               $ajaxRegistryEntry = isset($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'][$ajaxID]) ? $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'][$ajaxID] : NULL;
-               $ajaxScript = NULL;
-               $csrfTokenCheck = FALSE;
-               if ($ajaxRegistryEntry !== NULL && is_array($ajaxRegistryEntry) && isset($ajaxRegistryEntry['callbackMethod'])) {
-                       $ajaxScript = $ajaxRegistryEntry['callbackMethod'];
-                       $csrfTokenCheck = $ajaxRegistryEntry['csrfTokenCheck'];
-               }
-
-               // Instantiating the AJAX object
-               $ajaxObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\AjaxRequestHandler::class, $ajaxID);
-               $ajaxParams = array();
-
-               // Evaluating the arguments and calling the AJAX method/function
-               if (empty($ajaxID)) {
-                       $ajaxObj->setError('No valid ajaxID parameter given.');
-               } elseif (empty($ajaxScript)) {
-                       $ajaxObj->setError('No backend function registered for ajaxID "' . $ajaxID . '".');
-               } else {
-                       $success = TRUE;
-                       $tokenIsValid = TRUE;
-                       if ($csrfTokenCheck) {
-                               $tokenIsValid = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->validateToken(GeneralUtility::_GP('ajaxToken'), 'ajaxCall', $ajaxID);
-                       }
-                       if ($tokenIsValid) {
-                               // Cleanup global variable space
-                               unset($csrfTokenCheck, $ajaxRegistryEntry, $tokenIsValid, $success);
-                               $success = GeneralUtility::callUserFunction($ajaxScript, $ajaxParams, $ajaxObj, FALSE, TRUE);
-                       } else {
-                               $ajaxObj->setError('Invalid CSRF token detected for ajaxID "' . $ajaxID . '"!');
-                       }
-                       if ($success === FALSE) {
-                               $ajaxObj->setError('Registered backend function for ajaxID "' . $ajaxID . '" was not found.');
-                       }
-               }
-
-               // Outputting the content (and setting the X-JSON-Header)
-               $ajaxObj->render();
-       }
-
-       /**
-        * This request handler can handle any backend request coming from ajax.php
-        *
-        * @return bool If the request is an AJAX backend request, TRUE otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX;
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 80;
-       }
-
-       /**
-        * Start the Backend bootstrap part
-        *
-        * @param string $ajaxId Contains the string of the ajaxId used
-        */
-       protected function boot($ajaxId) {
-               // If we're trying to do an ajax login, don't require a user
-               $proceedIfNoUserIsLoggedIn = in_array($ajaxId, $this->publicAjaxIds, TRUE);
-
-               $this->bootstrap
-                       ->checkLockedBackendAndRedirectOrDie($proceedIfNoUserIsLoggedIn)
-                       ->checkBackendIpOrDie()
-                       ->checkSslBackendAndRedirectIfNeeded()
-                       ->checkValidBrowserOrDie()
-                       ->loadExtensionTables(TRUE)
-                       ->initializeSpriteManager()
-                       ->initializeBackendUser()
-                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
-                       ->initializeLanguageObject()
-                       ->initializeBackendTemplate()
-                       ->endOutputBufferingAndCleanPreviousOutput()
-                       ->initializeOutputCompression()
-                       ->sendHttpHeaders();
-       }
-}
diff --git a/typo3/sysext/backend/Classes/BackendModuleRequestHandler.php b/typo3/sysext/backend/Classes/BackendModuleRequestHandler.php
deleted file mode 100644 (file)
index 2221c39..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
-use TYPO3\CMS\Core\Exception;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-
-/**
- * Handles the request for backend modules and wizards
- */
-class BackendModuleRequestHandler implements \TYPO3\CMS\Core\Core\RequestHandlerInterface {
-
-       /**
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * @var array
-        */
-       protected $moduleRegistry = array();
-
-       /**
-        * @var BackendUserAuthentication
-        */
-       protected $backendUserAuthentication;
-
-       /**
-        * @param Bootstrap $bootstrap The TYPO3 core bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles the request, evaluating the configuration and executes the module accordingly
-        *
-        * @throws Exception
-        */
-       public function handleRequest() {
-               $this->boot();
-
-               $this->moduleRegistry = $GLOBALS['TBE_MODULES'];
-
-               if (!$this->isValidModuleRequest()) {
-                       throw new Exception('The CSRF protection token for the requested module is missing or invalid', 1417988921);
-               }
-
-               // Set to empty as it is not needed / always coming from typo3/mod.php
-               $GLOBALS['BACK_PATH'] = '';
-
-               $this->backendUserAuthentication = $GLOBALS['BE_USER'];
-
-               $moduleName = (string)GeneralUtility::_GET('M');
-               if ($this->isDispatchedModule($moduleName)) {
-                       $isDispatched = $this->dispatchModule($moduleName);
-               } else {
-                       $isDispatched = $this->callTraditionalModule($moduleName);
-               }
-               if ($isDispatched === FALSE) {
-                       throw new Exception('No module "' . $moduleName . '" could be found.', 1294585070);
-               }
-       }
-
-       /**
-        * Execute TYPO3 bootstrap
-        */
-       protected function boot() {
-               // Evaluate the constant for skipping the BE user check for the bootstrap, will be done without the constant at a later point
-               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
-                       $proceedIfNoUserIsLoggedIn = TRUE;
-               } else {
-                       $proceedIfNoUserIsLoggedIn = FALSE;
-               }
-
-               $this->bootstrap->checkLockedBackendAndRedirectOrDie()
-                       ->checkBackendIpOrDie()
-                       ->checkSslBackendAndRedirectIfNeeded()
-                       ->checkValidBrowserOrDie()
-                       ->loadExtensionTables(TRUE)
-                       ->initializeSpriteManager()
-                       ->initializeBackendUser()
-                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
-                       ->initializeLanguageObject()
-                       ->initializeBackendTemplate()
-                       ->endOutputBufferingAndCleanPreviousOutput()
-                       ->initializeOutputCompression()
-                       ->sendHttpHeaders();
-       }
-
-       /**
-        * This request handler can handle any backend request coming from mod.php
-        *
-        * @return bool
-        */
-       public function canHandleRequest() {
-               return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && !empty((string)GeneralUtility::_GET('M'));
-       }
-
-       /**
-        * Checks if all parameters are met.
-        *
-        * @return bool
-        */
-       protected function isValidModuleRequest() {
-               return $this->getFormProtection()->validateToken((string)GeneralUtility::_GP('moduleToken'), 'moduleCall', (string)GeneralUtility::_GET('M'));
-       }
-
-       /**
-        * A dispatched module, currently only Extbase modules are dispatched,
-        * traditional modules have a module path set.
-        *
-        * @param string $moduleName
-        * @return bool
-        */
-       protected function isDispatchedModule($moduleName) {
-               return empty($this->moduleRegistry['_PATHS'][$moduleName]);
-       }
-
-       /**
-        * Executes the module dispatcher which calls the module appropriately.
-        * Currently only used by Extbase
-        *
-        * @param string $moduleName
-        * @return bool
-        */
-       protected function dispatchModule($moduleName) {
-               if (is_array($this->moduleRegistry['_dispatcher'])) {
-                       foreach ($this->moduleRegistry['_dispatcher'] as $dispatcherClassName) {
-                               $dispatcher = GeneralUtility::makeInstance(ObjectManager::class)->get($dispatcherClassName);
-                               if ($dispatcher->callModule($moduleName) === TRUE) {
-                                       return TRUE;
-                                       break;
-                               }
-                       }
-               }
-               return FALSE;
-       }
-
-       /**
-        * Calls traditional modules which are identified by having a index.php in their directory
-        * and were previously located within the global scope.
-        *
-        * @param string $moduleName
-        * @return bool
-        */
-       protected function callTraditionalModule($moduleName) {
-               $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName];
-               $GLOBALS['MCONF'] = $moduleConfiguration = $this->getModuleConfiguration($moduleName);
-               if (!empty($moduleConfiguration['access'])) {
-                       $this->backendUserAuthentication->modAccess($moduleConfiguration, TRUE);
-               }
-               if (file_exists($moduleBasePath . 'index.php')) {
-                       global $SOBE;
-                       require $moduleBasePath . 'index.php';
-                       return TRUE;
-               }
-               return FALSE;
-       }
-
-       /**
-        * Returns the module configuration which is either provided in a conf.php file
-        * or during module registration
-        *
-        * @param string $moduleName
-        * @return array
-        */
-       protected function getModuleConfiguration($moduleName) {
-               $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName];
-               if (file_exists($moduleBasePath . 'conf.php')) {
-                       // Some modules still rely on this global configuration array in a conf.php file
-                       require $moduleBasePath . 'conf.php';
-                       $moduleConfiguration = $MCONF;
-               } else {
-                       $moduleConfiguration = $this->moduleRegistry['_configuration'][$moduleName];
-               }
-               return $moduleConfiguration;
-       }
-
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 90;
-       }
-
-       /**
-        * Wrapper method for static form protection utility
-        *
-        * @return \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
-        */
-       protected function getFormProtection() {
-               return FormProtectionFactory::get();
-       }
-
-}
diff --git a/typo3/sysext/backend/Classes/CliRequestHandler.php b/typo3/sysext/backend/Classes/CliRequestHandler.php
deleted file mode 100644 (file)
index 3a05300..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Command Line Interface Request Handler dealing with "cliKey"-based Commands from the cli_dispatch.phpsh script.
- * Picks up requests only when coming from the CLI mode.
- * Resolves the "cliKey" which is registered inside $TYPO3_CONF_VARS[SC_OPTIONS][GLOBAL][cliKeys]
- * and includes the CLI-based script or exits if no valid "cliKey" is found.
- */
-class CliRequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles any commandline request
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               $commandLineKey = $this->getCommandLineKeyOrDie();
-               $commandLineScript = $this->getIncludeScriptByCommandLineKey($commandLineKey);
-
-               $this->boot();
-
-               try {
-                       include($commandLineScript);
-               } catch (\Exception $e) {
-                       fwrite(STDERR, $e->getMessage() . LF);
-                       exit(99);
-               }
-       }
-
-       /**
-        * Execute TYPO3 bootstrap
-        */
-       protected function boot() {
-               // Evaluate the constant for skipping the BE user check for the bootstrap
-               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
-                       $proceedIfNoUserIsLoggedIn = TRUE;
-               } else {
-                       $proceedIfNoUserIsLoggedIn = FALSE;
-               }
-
-               $this->bootstrap
-                       ->loadExtensionTables(TRUE)
-                       ->initializeBackendUser()
-                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
-                       ->initializeLanguageObject();
-
-               // Make sure output is not buffered, so command-line output and interaction can take place
-               GeneralUtility::flushOutputBuffers();
-       }
-
-       /**
-        * Check CLI parameters.
-        * First argument is a key that points to the script configuration.
-        * If it is not set or not valid, the script exits with an error message.
-        *
-        * @return string the CLI key in use
-        */
-       protected function getCommandLineKeyOrDie() {
-               $cliKey = $_SERVER['argv'][1];
-               $errorMessage = '';
-               if (empty($cliKey)) {
-                       $errorMessage = 'This script must have a \'cliKey\' as first argument.';
-               } elseif (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$cliKey])) {
-                       $errorMessage = 'The supplied \'cliKey\' is not valid.';
-               }
-
-               // exit with an error message
-               if (!empty($errorMessage)) {
-                       $errorMessage .= ' Valid keys are:
-
-';
-                       $cliKeys = array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']);
-                       asort($cliKeys);
-                       foreach ($cliKeys as $key => $value) {
-                               $errorMessage .= '  ' . $value . LF;
-                       }
-                       fwrite(STDERR, $errorMessage . LF);
-                       die(1);
-               }
-
-               return $cliKey;
-       }
-
-       /**
-        * Define cli-related parameters and return the include script.
-        *
-        * @param string $cliKey the CLI key
-        * @return string the absolute path to the include script
-        */
-       protected function getIncludeScriptByCommandLineKey($cliKey) {
-               list($commandLineScript, $commandLineName) = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$cliKey];
-               $commandLineScript = GeneralUtility::getFileAbsFileName($commandLineScript);
-               // Note: These constants are not in use anymore
-               define('TYPO3_cliKey', $cliKey);
-               define('TYPO3_cliInclude', $commandLineScript);
-               $GLOBALS['MCONF']['name'] = $commandLineName;
-               // This is a compatibility layer: Some cli scripts rely on this, like ext:phpunit cli
-               $GLOBALS['temp_cliScriptPath'] = array_shift($_SERVER['argv']);
-               $GLOBALS['temp_cliKey'] = array_shift($_SERVER['argv']);
-               array_unshift($_SERVER['argv'], $GLOBALS['temp_cliScriptPath']);
-               return $commandLineScript;
-       }
-
-       /**
-        * This request handler can handle any CLI request .
-        *
-        * @return bool If the request is a CLI request, TRUE otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return defined('TYPO3_cliMode') && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI);
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 50;
-       }
-}
diff --git a/typo3/sysext/backend/Classes/Console/Application.php b/typo3/sysext/backend/Classes/Console/Application.php
new file mode 100644 (file)
index 0000000..a6f4ee8
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace TYPO3\CMS\Backend\Console;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Core\ApplicationInterface;
+use TYPO3\CMS\Core\Core\Bootstrap;
+
+
+/**
+ * Entry point for the TYPO3 Command Line for Backend calls
+ */
+class Application implements ApplicationInterface {
+
+       /**
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        *
+        * @var string
+        */
+       protected $entryPointPath = 'typo3/';
+
+       /**
+        * All available request handlers that can deal with a CLI Request
+        * @var array
+        */
+       protected $availableRequestHandlers = array(
+               \TYPO3\CMS\Backend\Console\CliRequestHandler::class
+       );
+
+       /**
+        * Constructor setting up legacy constants and register available Request Handlers
+        *
+        * @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
+        */
+       public function __construct($classLoader) {
+               $this->defineLegacyConstants();
+
+               \TYPO3\CMS\Core\Core\CliBootstrap::checkEnvironmentOrDie();
+
+               $this->bootstrap = Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader);
+
+               foreach ($this->availableRequestHandlers as $requestHandler) {
+                       $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
+               }
+       }
+
+       /**
+        * Set up the application and shut it down afterwards
+        *
+        * @param callable $execute
+        * @return void
+        */
+       public function run(callable $execute = NULL) {
+               $this->bootstrap->run();
+
+               if ($execute !== NULL) {
+                       if ($execute instanceof \Closure) {
+                               $execute->bindTo($this);
+                       }
+                       call_user_func($execute);
+               }
+
+               $this->bootstrap->shutdown();
+       }
+
+       /**
+        * Define constants and variables
+        */
+       protected function defineLegacyConstants() {
+               define('TYPO3_MODE', 'BE');
+               define('TYPO3_cliMode', TRUE);
+       }
+}
diff --git a/typo3/sysext/backend/Classes/Console/CliRequestHandler.php b/typo3/sysext/backend/Classes/Console/CliRequestHandler.php
new file mode 100644 (file)
index 0000000..62d4a39
--- /dev/null
@@ -0,0 +1,154 @@
+<?php
+namespace TYPO3\CMS\Backend\Console;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Command Line Interface Request Handler dealing with "cliKey"-based Commands from the cli_dispatch.phpsh script.
+ * Picks up requests only when coming from the CLI mode.
+ * Resolves the "cliKey" which is registered inside $TYPO3_CONF_VARS[SC_OPTIONS][GLOBAL][cliKeys]
+ * and includes the CLI-based script or exits if no valid "cliKey" is found.
+ */
+class CliRequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles any commandline request
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               $commandLineKey = $this->getCommandLineKeyOrDie();
+               $commandLineScript = $this->getIncludeScriptByCommandLineKey($commandLineKey);
+
+               $this->boot();
+
+               try {
+                       include($commandLineScript);
+               } catch (\Exception $e) {
+                       fwrite(STDERR, $e->getMessage() . LF);
+                       exit(99);
+               }
+       }
+
+       /**
+        * Execute TYPO3 bootstrap
+        */
+       protected function boot() {
+               // Evaluate the constant for skipping the BE user check for the bootstrap
+               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
+                       $proceedIfNoUserIsLoggedIn = TRUE;
+               } else {
+                       $proceedIfNoUserIsLoggedIn = FALSE;
+               }
+
+               $this->bootstrap
+                       ->loadExtensionTables(TRUE)
+                       ->initializeBackendUser()
+                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
+                       ->initializeLanguageObject();
+
+               // Make sure output is not buffered, so command-line output and interaction can take place
+               GeneralUtility::flushOutputBuffers();
+       }
+
+       /**
+        * Check CLI parameters.
+        * First argument is a key that points to the script configuration.
+        * If it is not set or not valid, the script exits with an error message.
+        *
+        * @return string the CLI key in use
+        */
+       protected function getCommandLineKeyOrDie() {
+               $cliKey = $_SERVER['argv'][1];
+               $errorMessage = '';
+               if (empty($cliKey)) {
+                       $errorMessage = 'This script must have a \'cliKey\' as first argument.';
+               } elseif (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$cliKey])) {
+                       $errorMessage = 'The supplied \'cliKey\' is not valid.';
+               }
+
+               // exit with an error message
+               if (!empty($errorMessage)) {
+                       $errorMessage .= ' Valid keys are:
+
+';
+                       $cliKeys = array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']);
+                       asort($cliKeys);
+                       foreach ($cliKeys as $key => $value) {
+                               $errorMessage .= '  ' . $value . LF;
+                       }
+                       fwrite(STDERR, $errorMessage . LF);
+                       die(1);
+               }
+
+               return $cliKey;
+       }
+
+       /**
+        * Define cli-related parameters and return the include script.
+        *
+        * @param string $cliKey the CLI key
+        * @return string the absolute path to the include script
+        */
+       protected function getIncludeScriptByCommandLineKey($cliKey) {
+               list($commandLineScript, $commandLineName) = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$cliKey];
+               $commandLineScript = GeneralUtility::getFileAbsFileName($commandLineScript);
+               // Note: These constants are not in use anymore
+               define('TYPO3_cliKey', $cliKey);
+               define('TYPO3_cliInclude', $commandLineScript);
+               $GLOBALS['MCONF']['name'] = $commandLineName;
+               // This is a compatibility layer: Some cli scripts rely on this, like ext:phpunit cli
+               $GLOBALS['temp_cliScriptPath'] = array_shift($_SERVER['argv']);
+               $GLOBALS['temp_cliKey'] = array_shift($_SERVER['argv']);
+               array_unshift($_SERVER['argv'], $GLOBALS['temp_cliScriptPath']);
+               return $commandLineScript;
+       }
+
+       /**
+        * This request handler can handle any CLI request .
+        *
+        * @return bool If the request is a CLI request, TRUE otherwise FALSE
+        */
+       public function canHandleRequest() {
+               return defined('TYPO3_cliMode') && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI);
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 50;
+       }
+}
diff --git a/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php b/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php
new file mode 100644 (file)
index 0000000..ac11642
--- /dev/null
@@ -0,0 +1,157 @@
+<?php
+namespace TYPO3\CMS\Backend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Base class for all AJAX-related calls for the TYPO3 Backend run through typo3/ajax.php.
+ * Before doing the basic BE-related set up of this request (see the additional calls on $this->bootstrap inside
+ * handleRequest()), some AJAX-calls can be made without a valid user, which is determined here.
+ *
+ * Due to legacy reasons, the actual logic is in EXT:core/Http/AjaxRequestHandler which will eventually
+ * be moved into this class.
+ * In the future, the logic for "TYPO3_PROCEED_IF_NO_USER" will be moved in here as well.
+ */
+class AjaxRequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * List of requests that don't need a valid BE user
+        * @var array
+        */
+       protected $publicAjaxIds = array(
+               'BackendLogin::login',
+               'BackendLogin::logout',
+               'BackendLogin::refreshLogin',
+               'BackendLogin::isTimedOut',
+               'BackendLogin::getChallenge',
+               'BackendLogin::getRsaPublicKey'
+       );
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles any AJAX request in the TYPO3 Backend
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               // First get the ajaxID
+               $ajaxID = isset($_POST['ajaxID']) ? $_POST['ajaxID'] : $_GET['ajaxID'];
+               if (isset($ajaxID)) {
+                       $ajaxID = (string)stripslashes($ajaxID);
+               }
+
+               $GLOBALS['ajaxID'] = $ajaxID;
+               $this->boot($ajaxID);
+
+               // Finding the script path from the registry
+               $ajaxRegistryEntry = isset($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'][$ajaxID]) ? $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'][$ajaxID] : NULL;
+               $ajaxScript = NULL;
+               $csrfTokenCheck = FALSE;
+               if ($ajaxRegistryEntry !== NULL && is_array($ajaxRegistryEntry) && isset($ajaxRegistryEntry['callbackMethod'])) {
+                       $ajaxScript = $ajaxRegistryEntry['callbackMethod'];
+                       $csrfTokenCheck = $ajaxRegistryEntry['csrfTokenCheck'];
+               }
+
+               // Instantiating the AJAX object
+               $ajaxObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\AjaxRequestHandler::class, $ajaxID);
+               $ajaxParams = array();
+
+               // Evaluating the arguments and calling the AJAX method/function
+               if (empty($ajaxID)) {
+                       $ajaxObj->setError('No valid ajaxID parameter given.');
+               } elseif (empty($ajaxScript)) {
+                       $ajaxObj->setError('No backend function registered for ajaxID "' . $ajaxID . '".');
+               } else {
+                       $success = TRUE;
+                       $tokenIsValid = TRUE;
+                       if ($csrfTokenCheck) {
+                               $tokenIsValid = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->validateToken(GeneralUtility::_GP('ajaxToken'), 'ajaxCall', $ajaxID);
+                       }
+                       if ($tokenIsValid) {
+                               // Cleanup global variable space
+                               unset($csrfTokenCheck, $ajaxRegistryEntry, $tokenIsValid, $success);
+                               $success = GeneralUtility::callUserFunction($ajaxScript, $ajaxParams, $ajaxObj, FALSE, TRUE);
+                       } else {
+                               $ajaxObj->setError('Invalid CSRF token detected for ajaxID "' . $ajaxID . '"!');
+                       }
+                       if ($success === FALSE) {
+                               $ajaxObj->setError('Registered backend function for ajaxID "' . $ajaxID . '" was not found.');
+                       }
+               }
+
+               // Outputting the content (and setting the X-JSON-Header)
+               $ajaxObj->render();
+       }
+
+       /**
+        * This request handler can handle any backend request coming from ajax.php
+        *
+        * @return bool If the request is an AJAX backend request, TRUE otherwise FALSE
+        */
+       public function canHandleRequest() {
+               return TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX;
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 80;
+       }
+
+       /**
+        * Start the Backend bootstrap part
+        *
+        * @param string $ajaxId Contains the string of the ajaxId used
+        */
+       protected function boot($ajaxId) {
+               // If we're trying to do an ajax login, don't require a user
+               $proceedIfNoUserIsLoggedIn = in_array($ajaxId, $this->publicAjaxIds, TRUE);
+
+               $this->bootstrap
+                       ->checkLockedBackendAndRedirectOrDie($proceedIfNoUserIsLoggedIn)
+                       ->checkBackendIpOrDie()
+                       ->checkSslBackendAndRedirectIfNeeded()
+                       ->checkValidBrowserOrDie()
+                       ->loadExtensionTables(TRUE)
+                       ->initializeSpriteManager()
+                       ->initializeBackendUser()
+                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
+                       ->initializeLanguageObject()
+                       ->initializeBackendTemplate()
+                       ->endOutputBufferingAndCleanPreviousOutput()
+                       ->initializeOutputCompression()
+                       ->sendHttpHeaders();
+       }
+}
diff --git a/typo3/sysext/backend/Classes/Http/Application.php b/typo3/sysext/backend/Classes/Http/Application.php
new file mode 100644 (file)
index 0000000..01ebd90
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+namespace TYPO3\CMS\Backend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Core\ApplicationInterface;
+use TYPO3\CMS\Core\Core\Bootstrap;
+
+
+/**
+ * Entry point for the TYPO3 Backend (HTTP requests)
+ */
+class Application implements ApplicationInterface {
+
+       /**
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * @var string
+        */
+       protected $entryPointPath = 'typo3/';
+
+       /**
+        * All available request handlers that can handle backend requests (non-CLI)
+        * @var array
+        */
+       protected $availableRequestHandlers = array(
+               \TYPO3\CMS\Backend\Http\RequestHandler::class,
+               \TYPO3\CMS\Backend\Http\BackendModuleRequestHandler::class,
+               \TYPO3\CMS\Backend\Http\AjaxRequestHandler::class
+       );
+
+       /**
+        * Constructor setting up legacy constant and register available Request Handlers
+        *
+        * @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
+        */
+       public function __construct($classLoader) {
+               $this->defineLegacyConstants();
+
+               $this->bootstrap = Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader)
+                       ->baseSetup($this->entryPointPath);
+
+               // can be done here after the base setup is done
+               $this->defineAdditionalEntryPointRelatedConstants();
+
+               // Redirect to install tool if base configuration is not found
+               if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
+                       $this->bootstrap->redirectToInstallTool($this->entryPointPath);
+               }
+
+               foreach ($this->availableRequestHandlers as $requestHandler) {
+                       $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
+               }
+       }
+
+       /**
+        * Set up the application and shut it down afterwards
+        *
+        * @param callable $execute
+        * @return void
+        */
+       public function run(callable $execute = NULL) {
+               $this->bootstrap->run();
+
+               if ($execute !== NULL) {
+                       if ($execute instanceof \Closure) {
+                               $execute->bindTo($this);
+                       }
+                       call_user_func($execute);
+               }
+
+               $this->bootstrap->shutdown();
+       }
+
+       /**
+        * Define constants and variables
+        */
+       protected function defineLegacyConstants() {
+               define('TYPO3_MODE', 'BE');
+       }
+
+       /**
+        * Define values that are based on the current script
+        */
+       protected function defineAdditionalEntryPointRelatedConstants() {
+               $currentScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
+
+               // activate "AJAX" handler when called via ajax.php
+               if (substr($currentScript, -15) === '/typo3/ajax.php') {
+                       $GLOBALS['TYPO3_AJAX'] = TRUE;
+               }
+               // allow backend login to work
+               if (substr($currentScript, -16) === '/typo3/index.php') {
+                       define('TYPO3_PROCEED_IF_NO_USER', 1);
+               }
+       }
+}
diff --git a/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php b/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php
new file mode 100644 (file)
index 0000000..c06b092
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+namespace TYPO3\CMS\Backend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
+use TYPO3\CMS\Core\Exception;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+
+/**
+ * Handles the request for backend modules and wizards
+ */
+class BackendModuleRequestHandler implements \TYPO3\CMS\Core\Core\RequestHandlerInterface {
+
+       /**
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * @var array
+        */
+       protected $moduleRegistry = array();
+
+       /**
+        * @var BackendUserAuthentication
+        */
+       protected $backendUserAuthentication;
+
+       /**
+        * @param Bootstrap $bootstrap The TYPO3 core bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles the request, evaluating the configuration and executes the module accordingly
+        *
+        * @throws Exception
+        */
+       public function handleRequest() {
+               $this->boot();
+
+               $this->moduleRegistry = $GLOBALS['TBE_MODULES'];
+
+               if (!$this->isValidModuleRequest()) {
+                       throw new Exception('The CSRF protection token for the requested module is missing or invalid', 1417988921);
+               }
+
+               // Set to empty as it is not needed / always coming from typo3/mod.php
+               $GLOBALS['BACK_PATH'] = '';
+
+               $this->backendUserAuthentication = $GLOBALS['BE_USER'];
+
+               $moduleName = (string)GeneralUtility::_GET('M');
+               if ($this->isDispatchedModule($moduleName)) {
+                       $isDispatched = $this->dispatchModule($moduleName);
+               } else {
+                       $isDispatched = $this->callTraditionalModule($moduleName);
+               }
+               if ($isDispatched === FALSE) {
+                       throw new Exception('No module "' . $moduleName . '" could be found.', 1294585070);
+               }
+       }
+
+       /**
+        * Execute TYPO3 bootstrap
+        */
+       protected function boot() {
+               // Evaluate the constant for skipping the BE user check for the bootstrap, will be done without the constant at a later point
+               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
+                       $proceedIfNoUserIsLoggedIn = TRUE;
+               } else {
+                       $proceedIfNoUserIsLoggedIn = FALSE;
+               }
+
+               $this->bootstrap->checkLockedBackendAndRedirectOrDie()
+                       ->checkBackendIpOrDie()
+                       ->checkSslBackendAndRedirectIfNeeded()
+                       ->checkValidBrowserOrDie()
+                       ->loadExtensionTables(TRUE)
+                       ->initializeSpriteManager()
+                       ->initializeBackendUser()
+                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
+                       ->initializeLanguageObject()
+                       ->initializeBackendTemplate()
+                       ->endOutputBufferingAndCleanPreviousOutput()
+                       ->initializeOutputCompression()
+                       ->sendHttpHeaders();
+       }
+
+       /**
+        * This request handler can handle any backend request coming from mod.php
+        *
+        * @return bool
+        */
+       public function canHandleRequest() {
+               return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && !empty((string)GeneralUtility::_GET('M'));
+       }
+
+       /**
+        * Checks if all parameters are met.
+        *
+        * @return bool
+        */
+       protected function isValidModuleRequest() {
+               return $this->getFormProtection()->validateToken((string)GeneralUtility::_GP('moduleToken'), 'moduleCall', (string)GeneralUtility::_GET('M'));
+       }
+
+       /**
+        * A dispatched module, currently only Extbase modules are dispatched,
+        * traditional modules have a module path set.
+        *
+        * @param string $moduleName
+        * @return bool
+        */
+       protected function isDispatchedModule($moduleName) {
+               return empty($this->moduleRegistry['_PATHS'][$moduleName]);
+       }
+
+       /**
+        * Executes the module dispatcher which calls the module appropriately.
+        * Currently only used by Extbase
+        *
+        * @param string $moduleName
+        * @return bool
+        */
+       protected function dispatchModule($moduleName) {
+               if (is_array($this->moduleRegistry['_dispatcher'])) {
+                       foreach ($this->moduleRegistry['_dispatcher'] as $dispatcherClassName) {
+                               $dispatcher = GeneralUtility::makeInstance(ObjectManager::class)->get($dispatcherClassName);
+                               if ($dispatcher->callModule($moduleName) === TRUE) {
+                                       return TRUE;
+                                       break;
+                               }
+                       }
+               }
+               return FALSE;
+       }
+
+       /**
+        * Calls traditional modules which are identified by having a index.php in their directory
+        * and were previously located within the global scope.
+        *
+        * @param string $moduleName
+        * @return bool
+        */
+       protected function callTraditionalModule($moduleName) {
+               $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName];
+               $GLOBALS['MCONF'] = $moduleConfiguration = $this->getModuleConfiguration($moduleName);
+               if (!empty($moduleConfiguration['access'])) {
+                       $this->backendUserAuthentication->modAccess($moduleConfiguration, TRUE);
+               }
+               if (file_exists($moduleBasePath . 'index.php')) {
+                       global $SOBE;
+                       require $moduleBasePath . 'index.php';
+                       return TRUE;
+               }
+               return FALSE;
+       }
+
+       /**
+        * Returns the module configuration which is either provided in a conf.php file
+        * or during module registration
+        *
+        * @param string $moduleName
+        * @return array
+        */
+       protected function getModuleConfiguration($moduleName) {
+               $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName];
+               if (file_exists($moduleBasePath . 'conf.php')) {
+                       // Some modules still rely on this global configuration array in a conf.php file
+                       require $moduleBasePath . 'conf.php';
+                       $moduleConfiguration = $MCONF;
+               } else {
+                       $moduleConfiguration = $this->moduleRegistry['_configuration'][$moduleName];
+               }
+               return $moduleConfiguration;
+       }
+
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 90;
+       }
+
+       /**
+        * Wrapper method for static form protection utility
+        *
+        * @return \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
+        */
+       protected function getFormProtection() {
+               return FormProtectionFactory::get();
+       }
+
+}
diff --git a/typo3/sysext/backend/Classes/Http/RequestHandler.php b/typo3/sysext/backend/Classes/Http/RequestHandler.php
new file mode 100644 (file)
index 0000000..bf4ed83
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+namespace TYPO3\CMS\Backend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+
+/**
+ * General RequestHandler for the TYPO3 Backend. This is used for all Backend requests except for CLI
+ * or AJAX calls. Unlike all other RequestHandlers in the TYPO3 CMS Core, the actual logic for choosing
+ * the controller is still done inside places like mod.php and each single file.
+ * This RequestHandler here serves solely to check and set up all requirements needed for a TYPO3 Backend.
+ * This class might be changed in the future.
+ */
+class RequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles any backend request
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               // Evaluate the constant for skipping the BE user check for the bootstrap
+               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
+                       $proceedIfNoUserIsLoggedIn = TRUE;
+               } else {
+                       $proceedIfNoUserIsLoggedIn = FALSE;
+               }
+
+               $this->bootstrap
+                       ->checkLockedBackendAndRedirectOrDie()
+                       ->checkBackendIpOrDie()
+                       ->checkSslBackendAndRedirectIfNeeded()
+                       ->checkValidBrowserOrDie()
+                       ->loadExtensionTables(TRUE)
+                       ->initializeSpriteManager()
+                       ->initializeBackendUser()
+                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
+                       ->initializeLanguageObject()
+                       ->initializeBackendTemplate()
+                       ->endOutputBufferingAndCleanPreviousOutput()
+                       ->initializeOutputCompression()
+                       ->sendHttpHeaders();
+       }
+
+       /**
+        * This request handler can handle any backend request (but not CLI).
+        *
+        * @return bool If the request is not a CLI script, TRUE otherwise FALSE
+        */
+       public function canHandleRequest() {
+               return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI));
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the
+        * request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 50;
+       }
+}
diff --git a/typo3/sysext/backend/Classes/RequestHandler.php b/typo3/sysext/backend/Classes/RequestHandler.php
deleted file mode 100644 (file)
index e2bae71..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-namespace TYPO3\CMS\Backend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-
-/**
- * General RequestHandler for the TYPO3 Backend. This is used for all Backend requests except for CLI
- * or AJAX calls. Unlike all other RequestHandlers in the TYPO3 CMS Core, the actual logic for choosing
- * the controller is still done inside places like mod.php and each single file.
- * This RequestHandler here serves solely to check and set up all requirements needed for a TYPO3 Backend.
- * This class might be changed in the future.
- */
-class RequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles any backend request
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               // Evaluate the constant for skipping the BE user check for the bootstrap
-               if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
-                       $proceedIfNoUserIsLoggedIn = TRUE;
-               } else {
-                       $proceedIfNoUserIsLoggedIn = FALSE;
-               }
-
-               $this->bootstrap
-                       ->checkLockedBackendAndRedirectOrDie()
-                       ->checkBackendIpOrDie()
-                       ->checkSslBackendAndRedirectIfNeeded()
-                       ->checkValidBrowserOrDie()
-                       ->loadExtensionTables(TRUE)
-                       ->initializeSpriteManager()
-                       ->initializeBackendUser()
-                       ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
-                       ->initializeLanguageObject()
-                       ->initializeBackendTemplate()
-                       ->endOutputBufferingAndCleanPreviousOutput()
-                       ->initializeOutputCompression()
-                       ->sendHttpHeaders();
-       }
-
-       /**
-        * This request handler can handle any backend request (but not CLI).
-        *
-        * @return bool If the request is not a CLI script, TRUE otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI));
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the
-        * request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 50;
-       }
-}
index 9ef4de9..654ef29 100644 (file)
@@ -15,9 +15,7 @@ namespace TYPO3\CMS\Backend\Tests\Unit;
  */
 
 use PHPUnit_Framework_MockObject_MockObject;
-use TYPO3\CMS\Backend\BackendModuleRequestHandler;
-use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
-use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Backend\Http\BackendModuleRequestHandler;
 use TYPO3\CMS\Core\FormProtection\AbstractFormProtection;
 use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
 use TYPO3\CMS\Core\Tests\UnitTestCase;
index 3a9d427..a2766a6 100644 (file)
@@ -171,9 +171,11 @@ class UnitTestsBootstrap {
         * @return UnitTestsBootstrap fluent interface
         */
        protected function includeAndStartCoreBootstrap() {
-               require_once PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
+               $classLoader = require PATH_site . '/typo3/contrib/vendor/autoload.php';
 
-               Bootstrap::getInstance()->baseSetup();
+               Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader)
+                       ->baseSetup();
 
                return $this;
        }
diff --git a/typo3/sysext/core/Classes/Core/ApplicationInterface.php b/typo3/sysext/core/Classes/Core/ApplicationInterface.php
new file mode 100644 (file)
index 0000000..83fea2f
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace TYPO3\CMS\Core\Core;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * The base ApplicationInterface which
+ * is used for all Entry Points for TYPO3, may it be
+ * Frontend, Backend, Install Tool or Command Line.
+ */
+interface ApplicationInterface {
+
+       /**
+        * Starting point
+        *
+        * @param callable $execute
+        * @return void
+        */
+       public function run(callable $execute = NULL);
+}
index b88a205..249e5fe 100644 (file)
@@ -114,10 +114,8 @@ class Bootstrap {
         */
        static public function getInstance() {
                if (is_null(static::$instance)) {
-                       $composerClassLoader = self::initializeComposerClassLoader();
                        $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
                        self::$instance = new static($applicationContext);
-                       self::$instance->setEarlyInstance(\Composer\Autoload\ClassLoader::class, $composerClassLoader);
                }
                return static::$instance;
        }
@@ -160,33 +158,32 @@ class Bootstrap {
         * and sets up the base request information for a regular request, then
         * resolves the RequestHandler which handles the request.
         *
-        * @param string $relativePathPart Relative path of entry script back to document root
+        * Make sure that the baseSetup() is called before and the class loader is present
+        *
         * @return Bootstrap
         */
-       public function run($relativePathPart = '') {
-               $this->baseSetup($relativePathPart);
+       public function run() {
+               $this->startOutputBuffering()
+                       ->loadConfigurationAndInitialize()
+                       ->loadTypo3LoadedExtAndExtLocalconf(TRUE)
+                       ->initializeExceptionHandling()
+                       ->setFinalCachingFrameworkCacheConfiguration()
+                       ->defineLoggingAndExceptionConstants()
+                       ->unsetReservedGlobalVariables()
+                       ->initializeTypo3DbGlobal()
+                       ->handleRequest();
 
-               // Failsafe minimal setup mode for the install tool
-               if (defined('TYPO3_enterInstallScript')) {
-                       $this->startOutputBuffering()
-                               ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class);
-               } elseif (!$this->checkIfEssentialConfigurationExists() && !defined('TYPO3_cliMode')) {
-                       // Redirect to install tool if base configuration is not found
-                       $this->redirectToInstallTool($relativePathPart);
-               } else {
-                       // Regular request (Frontend, AJAX, Backend, CLI)
-                       $this->startOutputBuffering()
-                               ->loadConfigurationAndInitialize()
-                               ->loadTypo3LoadedExtAndExtLocalconf(TRUE)
-                               ->initializeExceptionHandling()
-                               ->setFinalCachingFrameworkCacheConfiguration()
-                               ->defineLoggingAndExceptionConstants()
-                               ->unsetReservedGlobalVariables()
-                               ->initializeTypo3DbGlobal();
-               }
+               return $this;
+       }
 
-               // Resolve request handler that were registered based on TYPO3_MODE
-               $this->registerRequestHandlers();
+       /**
+        * Resolve the request handler that were registered based on the application
+        * and execute the request
+        *
+        * @return Bootstrap
+        * @throws \TYPO3\CMS\Core\Exception
+        */
+       public function handleRequest() {
                $requestHandler = $this->resolveRequestHandler();
                $requestHandler->handleRequest();
                return $this;
@@ -212,23 +209,17 @@ class Bootstrap {
        }
 
        /**
-        * @return \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader
+        * Sets the class loader to the bootstrap
+        *
+        * @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
+        * @return Bootstrap
         */
-       static protected function initializeComposerClassLoader() {
-               $possiblePaths = array(
-                       'distribution' => __DIR__ . '/../../../../../../Packages/Libraries/autoload.php',
-                       'fallback' => __DIR__ . '/../../../../contrib/vendor/autoload.php',
-               );
-               foreach ($possiblePaths as $autoLoadType => $possiblePath) {
-                       if (file_exists($possiblePath)) {
-                               if ($autoLoadType === 'distribution') {
-                                       self::$usesComposerClassLoading = TRUE;
-                               }
-                               return include $possiblePath;
-                       }
+       public function initializeClassLoader($classLoader) {
+               $this->setEarlyInstance(\Composer\Autoload\ClassLoader::class, $classLoader);
+               if (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE) {
+                       self::$usesComposerClassLoading = TRUE;
                }
-
-               throw new \LogicException('No class loading information found for TYPO3 CMS. Please make sure you installed TYPO3 with composer or the typo3/contrib/vendor folder is present.', 1425153762);
+               return $this;
        }
 
        /**
@@ -237,7 +228,7 @@ class Bootstrap {
         *
         * @return bool TRUE when the essential configuration is available, otherwise FALSE
         */
-       protected function checkIfEssentialConfigurationExists() {
+       public function checkIfEssentialConfigurationExists() {
                $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager;
                $this->setEarlyInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class, $configurationManager);
                return (!file_exists($configurationManager->getLocalConfigurationFileLocation()) || !file_exists(PATH_typo3conf . 'PackageStates.php')) ? FALSE : TRUE;
@@ -246,7 +237,6 @@ class Bootstrap {
        /**
         * Redirect to install tool if LocalConfiguration.php is missing.
         *
-        * @param string $relativePathPart Can contain '../' if called from a sub directory
         * @internal This is not a public API method, do not use in own extensions
         */
        public function redirectToInstallTool($relativePathPart = '') {
@@ -255,31 +245,13 @@ class Bootstrap {
        }
 
        /**
-        * Adds available request handlers, which currently hard-coded here based on the TYPO3_MODE. The extensability
-        * of adding own request handlers would be too complex for now, but can be added later.
+        * Adds available request handlers usually done via an application from the outside.
         *
+        * @param string $requestHandler class which implements the request handler interface
         * @return Bootstrap
-        * @internal This is not a public API method, do not use in own extensions
         */
-       protected function registerRequestHandlers() {
-               // Use the install tool handler if in install tool mode
-               if (!$this->checkIfEssentialConfigurationExists() || (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
-                       $this->availableRequestHandlers = array(
-                               \TYPO3\CMS\Install\RequestHandler::class
-                       );
-               } elseif (TYPO3_MODE == 'BE') {
-                       $this->availableRequestHandlers = array(
-                               \TYPO3\CMS\Backend\RequestHandler::class,
-                               \TYPO3\CMS\Backend\BackendModuleRequestHandler::class,
-                               \TYPO3\CMS\Backend\AjaxRequestHandler::class,
-                               \TYPO3\CMS\Backend\CliRequestHandler::class
-                       );
-               } elseif (TYPO3_MODE == 'FE') {
-                       $this->availableRequestHandlers = array(
-                               \TYPO3\CMS\Frontend\RequestHandler::class,
-                               \TYPO3\CMS\Frontend\EidRequestHandler::class
-                       );
-               }
+       public function registerRequestHandlerImplementation($requestHandler) {
+               $this->availableRequestHandlers[] = $requestHandler;
                return $this;
        }
 
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-67808-IntroduceApplicationClassesForEntryPointsAndEquivalentRequestHandlers.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-67808-IntroduceApplicationClassesForEntryPointsAndEquivalentRequestHandlers.rst
new file mode 100644 (file)
index 0000000..6b0d6c0
--- /dev/null
@@ -0,0 +1,37 @@
+===============================================================================================
+Feature: #67808 - Introduce Application classes for entry points and equivalent RequestHandlers
+===============================================================================================
+
+Description
+===========
+
+All entry points are encapsulating all previous initialization code in an Application class depending on the TYPO3_MODE
+and several context-dependant constraints. Each Application class registers Request Handlers to the TYPO3 Bootstrap to
+run a certain request type (e.g. eID or TSFE-logic, or AJAX requests in the Backend). Each Application is handed
+over the Class Loader provided by Composer.
+
+There are four types of Applications provided by the TYPO3 Core:
+
+TYPO3\CMS\Frontend\Http\Application
+-----------------------------------
+All incoming web requests coming to index.php in the main directory, handling all TSFE and eID requests.
+The Application sets TYPO3_MODE=FE very early.
+The Application checks if all configuration is given, otherwise redirects to the TYPO3 Install Tool.
+
+TYPO3\CMS\Backend\Http\Application
+----------------------------------
+All incoming web requests for any regular Backend call inside typo3/*. This handles three types of Request Handlers:
+- The AJAX Request Handler, which is triggered on requests with an "ajaxID" GET Parameter given.
+- The Backend Module Request Handler, which handles all types of modules triggered on requests with an "M" GET Parameter
+- The regular Request handler for typical other backend calls, e.g. index.php or backend.php.
+The Application checks if all configuration is given, otherwise redirects to the TYPO3 Install Tool.
+
+\TYPO3\CMS\Backend\Console\Application
+--------------------------------------
+All CLI Requests handled by cli_dispatch.php. Only executes the parts that are necessary for Backend CLI Scripts used
+with the cliKey syntax. The typical CliRequestHandler is used for handling requests set up by this Application.
+
+\TYPO3\CMS\Install\Http\Application
+-----------------------------------
+The install tool Application only runs with a very limited bootstrap set up with a Failsafe Package Manager not taking
+the ext_localconf.php scripts of installed extensions into account.
index fd1c40a..166f0bf 100644 (file)
@@ -428,8 +428,9 @@ class FunctionalTestCaseBootstrapUtility {
                require_once $this->instancePath . '/typo3/sysext/core/Classes/Core/CliBootstrap.php';
                \TYPO3\CMS\Core\Core\CliBootstrap::checkEnvironmentOrDie();
 
-               require_once $this->instancePath . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
+               $classLoader = require $this->instancePath . '/typo3/contrib/vendor/autoload.php';
                \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader)
                        ->baseSetup('')
                        ->loadConfigurationAndInitialize(TRUE)
                        ->loadTypo3LoadedExtAndExtLocalconf(TRUE)
diff --git a/typo3/sysext/frontend/Classes/EidRequestHandler.php b/typo3/sysext/frontend/Classes/EidRequestHandler.php
deleted file mode 100644 (file)
index febae47..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
-use TYPO3\CMS\Core\TimeTracker\TimeTracker;
-use TYPO3\CMS\Frontend\Utility\EidUtility;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-
-/**
- * Lightweight alternative to the regular RequestHandler used when $_GET[eID] is set.
- * In the future, logic from the EidUtility will be moved to this class.
- */
-class EidRequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles a frontend request based on the _GP "eID" variable.
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               // Timetracking started
-               $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
-               if (empty($configuredCookieName)) {
-                       $configuredCookieName = 'be_typo_user';
-               }
-               if ($_COOKIE[$configuredCookieName]) {
-                       $GLOBALS['TT'] = new TimeTracker();
-               } else {
-                       $GLOBALS['TT'] = new NullTimeTracker();
-               }
-
-               $GLOBALS['TT']->start();
-
-               // Hook to preprocess the current request
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
-                               $hookParameters = array();
-                               GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
-                       }
-                       unset($hookFunction);
-                       unset($hookParameters);
-               }
-
-               // Remove any output produced until now
-               $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
-               require EidUtility::getEidScriptPath();
-               $this->bootstrap->shutdown();
-               exit;
-       }
-
-       /**
-        * This request handler can handle any frontend request.
-        *
-        * @return bool If the request is not an eID request, TRUE otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return GeneralUtility::_GP('eID') ? TRUE : FALSE;
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the
-        * request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 80;
-       }
-}
diff --git a/typo3/sysext/frontend/Classes/Http/Application.php b/typo3/sysext/frontend/Classes/Http/Application.php
new file mode 100644 (file)
index 0000000..8c3f3d0
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace TYPO3\CMS\Frontend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Core\ApplicationInterface;
+use TYPO3\CMS\Core\Core\Bootstrap;
+
+
+/**
+ * Entry point for the TYPO3 Frontend
+ */
+class Application implements ApplicationInterface {
+
+       /**
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Usually this is equal to PATH_site = kept empty
+        * @var string
+        */
+       protected $entryPointPath = '';
+
+       /**
+        * All available request handlers that can deal with a Frontend Request
+        * @var array
+        */
+       protected $availableRequestHandlers = array(
+               \TYPO3\CMS\Frontend\Http\RequestHandler::class,
+               \TYPO3\CMS\Frontend\Http\EidRequestHandler::class
+       );
+
+       /**
+        * Constructor setting up legacy constant and register available Request Handlers
+        *
+        * @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
+        */
+       public function __construct($classLoader) {
+               $this->defineLegacyConstants();
+
+               $this->bootstrap = Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader)
+                       ->baseSetup($this->entryPointPath);
+
+               // Redirect to install tool if base configuration is not found
+               if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
+                       $this->bootstrap->redirectToInstallTool($this->entryPointPath);
+               }
+
+               foreach ($this->availableRequestHandlers as $requestHandler) {
+                       $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
+               }
+       }
+
+       /**
+        * Starting point
+        *
+        * @param callable $execute
+        * @return void
+        */
+       public function run(callable $execute = NULL) {
+               $this->bootstrap->run();
+
+               if ($execute !== NULL) {
+                       if ($execute instanceof \Closure) {
+                               $execute->bindTo($this);
+                       }
+                       call_user_func($execute);
+               }
+
+               $this->bootstrap->shutdown();
+       }
+
+       /**
+        * Define constants and variables
+        */
+       protected function defineLegacyConstants() {
+               define('TYPO3_MODE', 'FE');
+       }
+}
diff --git a/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php b/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php
new file mode 100644 (file)
index 0000000..a2fbef8
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+namespace TYPO3\CMS\Frontend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Frontend\Utility\EidUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+
+/**
+ * Lightweight alternative to the regular RequestHandler used when $_GET[eID] is set.
+ * In the future, logic from the EidUtility will be moved to this class.
+ */
+class EidRequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles a frontend request based on the _GP "eID" variable.
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               // Timetracking started
+               $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
+               if (empty($configuredCookieName)) {
+                       $configuredCookieName = 'be_typo_user';
+               }
+               if ($_COOKIE[$configuredCookieName]) {
+                       $GLOBALS['TT'] = new TimeTracker();
+               } else {
+                       $GLOBALS['TT'] = new NullTimeTracker();
+               }
+
+               $GLOBALS['TT']->start();
+
+               // Hook to preprocess the current request
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
+                               $hookParameters = array();
+                               GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
+                       }
+                       unset($hookFunction);
+                       unset($hookParameters);
+               }
+
+               // Remove any output produced until now
+               $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
+               require EidUtility::getEidScriptPath();
+               $this->bootstrap->shutdown();
+               exit;
+       }
+
+       /**
+        * This request handler can handle any frontend request.
+        *
+        * @return bool If the request is not an eID request, TRUE otherwise FALSE
+        */
+       public function canHandleRequest() {
+               return GeneralUtility::_GP('eID') ? TRUE : FALSE;
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the
+        * request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 80;
+       }
+}
diff --git a/typo3/sysext/frontend/Classes/Http/RequestHandler.php b/typo3/sysext/frontend/Classes/Http/RequestHandler.php
new file mode 100644 (file)
index 0000000..d11a1d6
--- /dev/null
@@ -0,0 +1,360 @@
+<?php
+namespace TYPO3\CMS\Frontend\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController;
+use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\MonitorUtility;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+use TYPO3\CMS\Frontend\Page\PageGenerator;
+use TYPO3\CMS\Frontend\Utility\CompressionUtility;
+use TYPO3\CMS\Frontend\View\AdminPanelView;
+
+/**
+ * This is the main entry point of the TypoScript driven standard front-end
+ *
+ * Basically put, this is the script which all requests for TYPO3 delivered pages goes to in the
+ * frontend (the website). The script instantiates a $TSFE object, includes libraries and does a little logic here
+ * and there in order to instantiate the right classes to create the webpage.
+ * Previously, this was called index_ts.php and also included the logic for the lightweight "eID" concept,
+ * which is now handled in a separate request handler (EidRequestHandler).
+ */
+class RequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Instance of the timetracker
+        * @var NullTimeTracker|TimeTracker
+        */
+       protected $timeTracker;
+
+       /**
+        * Instance of the TSFE object
+        * @var TypoScriptFrontendController
+        */
+       protected $controller;
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles a frontend request
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               $this->initializeTimeTracker();
+
+               // Hook to preprocess the current request:
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
+                               $hookParameters = array();
+                               GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
+                       }
+                       unset($hookFunction);
+                       unset($hookParameters);
+               }
+
+               $this->initializeController();
+
+               if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_force']
+                       && !GeneralUtility::cmpIP(
+                               GeneralUtility::getIndpEnv('REMOTE_ADDR'),
+                               $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])
+               ) {
+                       $this->controller->pageUnavailableAndExit('This page is temporarily unavailable.');
+               }
+
+               $this->controller->connectToDB();
+               $this->controller->sendRedirect();
+
+               // Output compression
+               // Remove any output produced until now
+               $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
+               $this->initializeOutputCompression();
+
+               // Initializing the Frontend User
+               $this->timeTracker->push('Front End user initialized', '');
+               $this->controller->initFEuser();
+               $this->timeTracker->pull();
+
+               // Initializing a possible logged-in Backend User
+               /** @var $GLOBALS['BE_USER'] \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */
+               $GLOBALS['BE_USER'] = $this->controller->initializeBackendUser();
+
+               // Process the ID, type and other parameters.
+               // After this point we have an array, $page in TSFE, which is the page-record
+               // of the current page, $id.
+               $this->timeTracker->push('Process ID', '');
+               // Initialize admin panel since simulation settings are required here:
+               if ($this->controller->isBackendUserLoggedIn()) {
+                       $GLOBALS['BE_USER']->initializeAdminPanel();
+                       $this->bootstrap->loadExtensionTables(TRUE);
+               } else {
+                       $this->bootstrap->loadCachedTca();
+               }
+               $this->controller->checkAlternativeIdMethods();
+               $this->controller->clear_preview();
+               $this->controller->determineId();
+
+               // Now, if there is a backend user logged in and he has NO access to this page,
+               // then re-evaluate the id shown! _GP('ADMCMD_noBeUser') is placed here because
+               // \TYPO3\CMS\Version\Hook\PreviewHook might need to know if a backend user is logged in.
+               if (
+                       $this->controller->isBackendUserLoggedIn()
+                       && (!$GLOBALS['BE_USER']->extPageReadAccess($this->controller->page) || GeneralUtility::_GP('ADMCMD_noBeUser'))
+               ) {
+                       // Remove user
+                       unset($GLOBALS['BE_USER']);
+                       $this->controller->beUserLogin = FALSE;
+                       // Re-evaluate the page-id.
+                       $this->controller->checkAlternativeIdMethods();
+                       $this->controller->clear_preview();
+                       $this->controller->determineId();
+               }
+
+               $this->controller->makeCacheHash();
+               $this->timeTracker->pull();
+
+               // Admin Panel & Frontend editing
+               if ($this->controller->isBackendUserLoggedIn()) {
+                       $GLOBALS['BE_USER']->initializeFrontendEdit();
+                       if ($GLOBALS['BE_USER']->adminPanel instanceof AdminPanelView) {
+                               $this->bootstrap
+                                       ->initializeLanguageObject()
+                                       ->initializeSpriteManager();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit instanceof FrontendEditingController) {
+                               $GLOBALS['BE_USER']->frontendEdit->initConfigOptions();
+                       }
+               }
+
+               // Starts the template
+               $this->timeTracker->push('Start Template', '');
+               $this->controller->initTemplate();
+               $this->timeTracker->pull();
+               // Get from cache
+               $this->timeTracker->push('Get Page from cache', '');
+               $this->controller->getFromCache();
+               $this->timeTracker->pull();
+               // Get config if not already gotten
+               // After this, we should have a valid config-array ready
+               $this->controller->getConfigArray();
+               // Setting language and locale
+               $this->timeTracker->push('Setting language and locale', '');
+               $this->controller->settingLanguage();
+               $this->controller->settingLocale();
+               $this->timeTracker->pull();
+
+               // Convert POST data to internal "renderCharset" if different from the metaCharset
+               $this->controller->convPOSTCharset();
+
+               // Check JumpUrl
+               $this->controller->setExternalJumpUrl();
+
+               $this->controller->handleDataSubmission();
+
+               // Check for shortcut page and redirect
+               $this->controller->checkPageForShortcutRedirect();
+               $this->controller->checkPageForMountpointRedirect();
+
+               // Generate page
+               $this->controller->setUrlIdToken();
+               $this->timeTracker->push('Page generation', '');
+               if ($this->controller->isGeneratePage()) {
+                       $this->controller->generatePage_preProcessing();
+                       $temp_theScript = $this->controller->generatePage_whichScript();
+                       if ($temp_theScript) {
+                               include $temp_theScript;
+                       } else {
+                               PageGenerator::pagegenInit();
+                               // Global content object
+                               $this->controller->newCObj();
+                               // Content generation
+                               if (!$this->controller->isINTincScript()) {
+                                       PageGenerator::renderContent();
+                                       $this->controller->setAbsRefPrefix();
+                               }
+                       }
+                       $this->controller->generatePage_postProcessing();
+               } elseif ($this->controller->isINTincScript()) {
+                       PageGenerator::pagegenInit();
+                       // Global content object
+                       $this->controller->newCObj();
+               }
+               $this->controller->releaseLocks();
+               $this->timeTracker->pull();
+
+               // Render non-cached parts
+               if ($this->controller->isINTincScript()) {
+                       $this->timeTracker->push('Non-cached objects', '');
+                       $this->controller->INTincScript();
+                       $this->timeTracker->pull();
+               }
+
+               // Output content
+               $sendTSFEContent = FALSE;
+               if ($this->controller->isOutputting()) {
+                       $this->timeTracker->push('Print Content', '');
+                       $this->controller->processOutput();
+                       $sendTSFEContent = TRUE;
+                       $this->timeTracker->pull();
+               }
+               // Store session data for fe_users
+               $this->controller->storeSessionData();
+               // Statistics
+               $GLOBALS['TYPO3_MISC']['microtime_end'] = microtime(TRUE);
+               $this->controller->setParseTime();
+               if (isset($this->controller->config['config']['debug'])) {
+                       $debugParseTime = (bool)$this->controller->config['config']['debug'];
+               } else {
+                       $debugParseTime = !empty($this->controller->TYPO3_CONF_VARS['FE']['debug']);
+               }
+               if ($this->controller->isOutputting() && $debugParseTime) {
+                       $this->controller->content .= LF . '<!-- Parsetime: ' . $this->controller->scriptParseTime . 'ms -->';
+               }
+               // Check JumpUrl
+               $this->controller->jumpurl();
+               // Preview info
+               $this->controller->previewInfo();
+               // Hook for end-of-frontend
+               $this->controller->hook_eofe();
+               // Finish timetracking
+               $this->timeTracker->pull();
+               // Check memory usage
+               MonitorUtility::peakMemoryUsage();
+               // beLoginLinkIPList
+               echo $this->controller->beLoginLinkIPList();
+
+               // Admin panel
+               if (
+                       $this->controller->isBackendUserLoggedIn()
+                       && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication
+                       && $GLOBALS['BE_USER']->isAdminPanelVisible()
+               ) {
+                       $this->controller->content = str_ireplace('</head>', $GLOBALS['BE_USER']->adminPanel->getAdminPanelHeaderData() . '</head>', $this->controller->content);
+                       $this->controller->content = str_ireplace('</body>', $GLOBALS['BE_USER']->displayAdminPanel() . '</body>', $this->controller->content);
+               }
+
+               if ($sendTSFEContent) {
+                       echo $this->controller->content;
+               }
+               // Debugging Output
+               if (isset($GLOBALS['error']) && is_object($GLOBALS['error']) && @is_callable(array($GLOBALS['error'], 'debugOutput'))) {
+                       $GLOBALS['error']->debugOutput();
+               }
+               if (TYPO3_DLOG) {
+                       GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, array('_FLUSH' => TRUE));
+               }
+       }
+
+       /**
+        * This request handler can handle any frontend request.
+        *
+        * @return bool If the request is not an eID request, TRUE otherwise FALSE
+        */
+       public function canHandleRequest() {
+               return GeneralUtility::_GP('eID') ? FALSE : TRUE;
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the
+        * request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 50;
+       }
+
+       /**
+        * Initializes output compression when enabled, could be split up and put into Bootstrap
+        * at a later point
+        */
+       protected function initializeOutputCompression() {
+               if ($GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'] && extension_loaded('zlib')) {
+                       if (MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'])) {
+                               @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel']);
+                       }
+                       ob_start(array(GeneralUtility::makeInstance(CompressionUtility::class), 'compressionOutputHandler'));
+               }
+       }
+
+       /**
+        * Timetracking started depending if a Backend User is logged in
+        *
+        * @return void
+        */
+       protected function initializeTimeTracker() {
+               $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
+               if (empty($configuredCookieName)) {
+                       $configuredCookieName = 'be_typo_user';
+               }
+               if ($_COOKIE[$configuredCookieName]) {
+                       $this->timeTracker = new TimeTracker();
+               } else {
+                       $this->timeTracker = new NullTimeTracker();
+               }
+
+               // We have to define this as reference here, because there is code around
+               // which exchanges the TT object in the global variable. The reference ensures
+               // that the $timeTracker member always works on the same object as the global variable.
+               // This is a dirty workaround and bypasses the protected access modifier of the $timeTracker member.
+               $GLOBALS['TT'] = &$this->timeTracker;
+               $this->timeTracker->start();
+       }
+
+       /**
+        * Creates an instance of TSFE and sets it as a global variable
+        *
+        * @return void
+        */
+       protected function initializeController() {
+               $this->controller = GeneralUtility::makeInstance(
+                       TypoScriptFrontendController::class,
+                       $GLOBALS['TYPO3_CONF_VARS'],
+                       GeneralUtility::_GP('id'),
+                       GeneralUtility::_GP('type'),
+                       GeneralUtility::_GP('no_cache'),
+                       GeneralUtility::_GP('cHash'),
+                       GeneralUtility::_GP('jumpurl'),
+                       GeneralUtility::_GP('MP'),
+                       GeneralUtility::_GP('RDCT')
+               );
+               // setting the global variable for the controller
+               // We have to define this as reference here, because there is code around
+               // which exchanges the TSFE object in the global variable. The reference ensures
+               // that the $controller member always works on the same object as the global variable.
+               // This is a dirty workaround and bypasses the protected access modifier of the controller member.
+               $GLOBALS['TSFE'] = &$this->controller;
+       }
+}
diff --git a/typo3/sysext/frontend/Classes/RequestHandler.php b/typo3/sysext/frontend/Classes/RequestHandler.php
deleted file mode 100644 (file)
index a87944a..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-<?php
-namespace TYPO3\CMS\Frontend;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController;
-use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
-use TYPO3\CMS\Core\TimeTracker\TimeTracker;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\MonitorUtility;
-use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\PageGenerator;
-use TYPO3\CMS\Frontend\Utility\CompressionUtility;
-use TYPO3\CMS\Frontend\View\AdminPanelView;
-
-/**
- * This is the main entry point of the TypoScript driven standard front-end
- *
- * Basically put, this is the script which all requests for TYPO3 delivered pages goes to in the
- * frontend (the website). The script instantiates a $TSFE object, includes libraries and does a little logic here
- * and there in order to instantiate the right classes to create the webpage.
- * Previously, this was called index_ts.php and also included the logic for the lightweight "eID" concept,
- * which is now handled in a separate request handler (EidRequestHandler).
- */
-class RequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * Instance of the timetracker
-        * @var NullTimeTracker|TimeTracker
-        */
-       protected $timeTracker;
-
-       /**
-        * Instance of the TSFE object
-        * @var TypoScriptFrontendController
-        */
-       protected $controller;
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles a frontend request
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               $this->initializeTimeTracker();
-
-               // Hook to preprocess the current request:
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
-                               $hookParameters = array();
-                               GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
-                       }
-                       unset($hookFunction);
-                       unset($hookParameters);
-               }
-
-               $this->initializeController();
-
-               if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_force']
-                       && !GeneralUtility::cmpIP(
-                               GeneralUtility::getIndpEnv('REMOTE_ADDR'),
-                               $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])
-               ) {
-                       $this->controller->pageUnavailableAndExit('This page is temporarily unavailable.');
-               }
-
-               $this->controller->connectToDB();
-               $this->controller->sendRedirect();
-
-               // Output compression
-               // Remove any output produced until now
-               $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
-               $this->initializeOutputCompression();
-
-               // Initializing the Frontend User
-               $this->timeTracker->push('Front End user initialized', '');
-               $this->controller->initFEuser();
-               $this->timeTracker->pull();
-
-               // Initializing a possible logged-in Backend User
-               /** @var $GLOBALS['BE_USER'] \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */
-               $GLOBALS['BE_USER'] = $this->controller->initializeBackendUser();
-
-               // Process the ID, type and other parameters.
-               // After this point we have an array, $page in TSFE, which is the page-record
-               // of the current page, $id.
-               $this->timeTracker->push('Process ID', '');
-               // Initialize admin panel since simulation settings are required here:
-               if ($this->controller->isBackendUserLoggedIn()) {
-                       $GLOBALS['BE_USER']->initializeAdminPanel();
-                       $this->bootstrap->loadExtensionTables(TRUE);
-               } else {
-                       $this->bootstrap->loadCachedTca();
-               }
-               $this->controller->checkAlternativeIdMethods();
-               $this->controller->clear_preview();
-               $this->controller->determineId();
-
-               // Now, if there is a backend user logged in and he has NO access to this page,
-               // then re-evaluate the id shown! _GP('ADMCMD_noBeUser') is placed here because
-               // \TYPO3\CMS\Version\Hook\PreviewHook might need to know if a backend user is logged in.
-               if (
-                       $this->controller->isBackendUserLoggedIn()
-                       && (!$GLOBALS['BE_USER']->extPageReadAccess($this->controller->page) || GeneralUtility::_GP('ADMCMD_noBeUser'))
-               ) {
-                       // Remove user
-                       unset($GLOBALS['BE_USER']);
-                       $this->controller->beUserLogin = FALSE;
-                       // Re-evaluate the page-id.
-                       $this->controller->checkAlternativeIdMethods();
-                       $this->controller->clear_preview();
-                       $this->controller->determineId();
-               }
-
-               $this->controller->makeCacheHash();
-               $this->timeTracker->pull();
-
-               // Admin Panel & Frontend editing
-               if ($this->controller->isBackendUserLoggedIn()) {
-                       $GLOBALS['BE_USER']->initializeFrontendEdit();
-                       if ($GLOBALS['BE_USER']->adminPanel instanceof AdminPanelView) {
-                               $this->bootstrap
-                                       ->initializeLanguageObject()
-                                       ->initializeSpriteManager();
-                       }
-                       if ($GLOBALS['BE_USER']->frontendEdit instanceof FrontendEditingController) {
-                               $GLOBALS['BE_USER']->frontendEdit->initConfigOptions();
-                       }
-               }
-
-               // Starts the template
-               $this->timeTracker->push('Start Template', '');
-               $this->controller->initTemplate();
-               $this->timeTracker->pull();
-               // Get from cache
-               $this->timeTracker->push('Get Page from cache', '');
-               $this->controller->getFromCache();
-               $this->timeTracker->pull();
-               // Get config if not already gotten
-               // After this, we should have a valid config-array ready
-               $this->controller->getConfigArray();
-               // Setting language and locale
-               $this->timeTracker->push('Setting language and locale', '');
-               $this->controller->settingLanguage();
-               $this->controller->settingLocale();
-               $this->timeTracker->pull();
-
-               // Convert POST data to internal "renderCharset" if different from the metaCharset
-               $this->controller->convPOSTCharset();
-
-               // Check JumpUrl
-               $this->controller->setExternalJumpUrl();
-
-               $this->controller->handleDataSubmission();
-
-               // Check for shortcut page and redirect
-               $this->controller->checkPageForShortcutRedirect();
-               $this->controller->checkPageForMountpointRedirect();
-
-               // Generate page
-               $this->controller->setUrlIdToken();
-               $this->timeTracker->push('Page generation', '');
-               if ($this->controller->isGeneratePage()) {
-                       $this->controller->generatePage_preProcessing();
-                       $temp_theScript = $this->controller->generatePage_whichScript();
-                       if ($temp_theScript) {
-                               include $temp_theScript;
-                       } else {
-                               PageGenerator::pagegenInit();
-                               // Global content object
-                               $this->controller->newCObj();
-                               // Content generation
-                               if (!$this->controller->isINTincScript()) {
-                                       PageGenerator::renderContent();
-                                       $this->controller->setAbsRefPrefix();
-                               }
-                       }
-                       $this->controller->generatePage_postProcessing();
-               } elseif ($this->controller->isINTincScript()) {
-                       PageGenerator::pagegenInit();
-                       // Global content object
-                       $this->controller->newCObj();
-               }
-               $this->controller->releaseLocks();
-               $this->timeTracker->pull();
-
-               // Render non-cached parts
-               if ($this->controller->isINTincScript()) {
-                       $this->timeTracker->push('Non-cached objects', '');
-                       $this->controller->INTincScript();
-                       $this->timeTracker->pull();
-               }
-
-               // Output content
-               $sendTSFEContent = FALSE;
-               if ($this->controller->isOutputting()) {
-                       $this->timeTracker->push('Print Content', '');
-                       $this->controller->processOutput();
-                       $sendTSFEContent = TRUE;
-                       $this->timeTracker->pull();
-               }
-               // Store session data for fe_users
-               $this->controller->storeSessionData();
-               // Statistics
-               $GLOBALS['TYPO3_MISC']['microtime_end'] = microtime(TRUE);
-               $this->controller->setParseTime();
-               if (isset($this->controller->config['config']['debug'])) {
-                       $debugParseTime = (bool)$this->controller->config['config']['debug'];
-               } else {
-                       $debugParseTime = !empty($this->controller->TYPO3_CONF_VARS['FE']['debug']);
-               }
-               if ($this->controller->isOutputting() && $debugParseTime) {
-                       $this->controller->content .= LF . '<!-- Parsetime: ' . $this->controller->scriptParseTime . 'ms -->';
-               }
-               // Check JumpUrl
-               $this->controller->jumpurl();
-               // Preview info
-               $this->controller->previewInfo();
-               // Hook for end-of-frontend
-               $this->controller->hook_eofe();
-               // Finish timetracking
-               $this->timeTracker->pull();
-               // Check memory usage
-               MonitorUtility::peakMemoryUsage();
-               // beLoginLinkIPList
-               echo $this->controller->beLoginLinkIPList();
-
-               // Admin panel
-               if (
-                       $this->controller->isBackendUserLoggedIn()
-                       && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication
-                       && $GLOBALS['BE_USER']->isAdminPanelVisible()
-               ) {
-                       $this->controller->content = str_ireplace('</head>', $GLOBALS['BE_USER']->adminPanel->getAdminPanelHeaderData() . '</head>', $this->controller->content);
-                       $this->controller->content = str_ireplace('</body>', $GLOBALS['BE_USER']->displayAdminPanel() . '</body>', $this->controller->content);
-               }
-
-               if ($sendTSFEContent) {
-                       echo $this->controller->content;
-               }
-               // Debugging Output
-               if (isset($GLOBALS['error']) && is_object($GLOBALS['error']) && @is_callable(array($GLOBALS['error'], 'debugOutput'))) {
-                       $GLOBALS['error']->debugOutput();
-               }
-               if (TYPO3_DLOG) {
-                       GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, array('_FLUSH' => TRUE));
-               }
-       }
-
-       /**
-        * This request handler can handle any frontend request.
-        *
-        * @return bool If the request is not an eID request, TRUE otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return GeneralUtility::_GP('eID') ? FALSE : TRUE;
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the
-        * request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 50;
-       }
-
-       /**
-        * Initializes output compression when enabled, could be split up and put into Bootstrap
-        * at a later point
-        */
-       protected function initializeOutputCompression() {
-               if ($GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'] && extension_loaded('zlib')) {
-                       if (MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'])) {
-                               @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel']);
-                       }
-                       ob_start(array(GeneralUtility::makeInstance(CompressionUtility::class), 'compressionOutputHandler'));
-               }
-       }
-
-       /**
-        * Timetracking started depending if a Backend User is logged in
-        *
-        * @return void
-        */
-       protected function initializeTimeTracker() {
-               $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
-               if (empty($configuredCookieName)) {
-                       $configuredCookieName = 'be_typo_user';
-               }
-               if ($_COOKIE[$configuredCookieName]) {
-                       $this->timeTracker = new TimeTracker();
-               } else {
-                       $this->timeTracker = new NullTimeTracker();
-               }
-
-               // We have to define this as reference here, because there is code around
-               // which exchanges the TT object in the global variable. The reference ensures
-               // that the $timeTracker member always works on the same object as the global variable.
-               // This is a dirty workaround and bypasses the protected access modifier of the $timeTracker member.
-               $GLOBALS['TT'] = &$this->timeTracker;
-               $this->timeTracker->start();
-       }
-
-       /**
-        * Creates an instance of TSFE and sets it as a global variable
-        *
-        * @return void
-        */
-       protected function initializeController() {
-               $this->controller = GeneralUtility::makeInstance(
-                       TypoScriptFrontendController::class,
-                       $GLOBALS['TYPO3_CONF_VARS'],
-                       GeneralUtility::_GP('id'),
-                       GeneralUtility::_GP('type'),
-                       GeneralUtility::_GP('no_cache'),
-                       GeneralUtility::_GP('cHash'),
-                       GeneralUtility::_GP('jumpurl'),
-                       GeneralUtility::_GP('MP'),
-                       GeneralUtility::_GP('RDCT')
-               );
-               // setting the global variable for the controller
-               // We have to define this as reference here, because there is code around
-               // which exchanges the TSFE object in the global variable. The reference ensures
-               // that the $controller member always works on the same object as the global variable.
-               // This is a dirty workaround and bypasses the protected access modifier of the controller member.
-               $GLOBALS['TSFE'] = &$this->controller;
-       }
-}
diff --git a/typo3/sysext/install/Classes/Http/Application.php b/typo3/sysext/install/Classes/Http/Application.php
new file mode 100644 (file)
index 0000000..4a44a26
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+namespace TYPO3\CMS\Install\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Core\ApplicationInterface;
+use TYPO3\CMS\Core\Core\Bootstrap;
+
+
+/**
+ * Entry point for the TYPO3 Install Tool
+ */
+class Application implements ApplicationInterface {
+
+       /**
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * @var string
+        */
+       protected $entryPointPath = 'typo3/sysext/install/Start/';
+
+       /**
+        * All available request handlers that can handle a install tool request
+        * @var array
+        */
+       protected $availableRequestHandlers = array(
+               \TYPO3\CMS\Install\Http\RequestHandler::class
+       );
+
+       /**
+        * Constructor setting up legacy constant and register available Request Handlers
+        *
+        * @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
+        */
+       public function __construct($classLoader) {
+               $this->defineLegacyConstants();
+
+               $this->bootstrap = Bootstrap::getInstance()
+                       ->initializeClassLoader($classLoader)
+                       ->baseSetup($this->entryPointPath);
+
+               foreach ($this->availableRequestHandlers as $requestHandler) {
+                       $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
+               }
+       }
+
+       /**
+        * Set up the application and shut it down afterwards
+        * Failsafe minimal setup mode for the install tool
+        * Does not call "run()" therefore
+        *
+        * @param callable $execute
+        * @return void
+        */
+       public function run(callable $execute = NULL) {
+               $this->bootstrap
+                       ->startOutputBuffering()
+                       ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class)
+                       ->handleRequest();
+
+               if ($execute !== NULL) {
+                       if ($execute instanceof \Closure) {
+                               $execute->bindTo($this);
+                       }
+                       call_user_func($execute);
+               }
+
+               $this->bootstrap->shutdown();
+       }
+
+       /**
+        * Define constants
+        */
+       protected function defineLegacyConstants() {
+               define('TYPO3_MODE', 'BE');
+               define('TYPO3_enterInstallScript', '1');
+       }
+}
diff --git a/typo3/sysext/install/Classes/Http/RequestHandler.php b/typo3/sysext/install/Classes/Http/RequestHandler.php
new file mode 100644 (file)
index 0000000..7bc2bee
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+namespace TYPO3\CMS\Install\Http;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\RequestHandlerInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Default request handler for all requests inside the TYPO3 Install Tool, which does a simple hardcoded
+ * dispatching to a controller based on the get/post variable.
+ */
+class RequestHandler implements RequestHandlerInterface {
+
+       /**
+        * Instance of the current TYPO3 bootstrap
+        * @var Bootstrap
+        */
+       protected $bootstrap;
+
+       /**
+        * Constructor handing over the bootstrap
+        *
+        * @param Bootstrap $bootstrap
+        */
+       public function __construct(Bootstrap $bootstrap) {
+               $this->bootstrap = $bootstrap;
+       }
+
+       /**
+        * Handles an install tool request
+        * Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
+        *
+        * @return void
+        */
+       public function handleRequest() {
+               $getPost = GeneralUtility::_GP('install');
+               switch ($getPost['controller']) {
+                       case 'tool':
+                               $controllerClassName = \TYPO3\CMS\Install\Controller\ToolController::class;
+                               break;
+                       case 'ajax':
+                               $controllerClassName = \TYPO3\CMS\Install\Controller\AjaxController::class;
+                               break;
+                       default:
+                               $controllerClassName = \TYPO3\CMS\Install\Controller\StepController::class;
+               }
+               GeneralUtility::makeInstance($controllerClassName)->execute();
+       }
+
+       /**
+        * This request handler can handle any request when not in CLI mode and the install tool flag is set
+        * please note that both checks are needed, as when in "failsafe" mode, the TYPO3_REQUESTTYPE is not
+        * necessarily set at this point.
+        *
+        * @return bool Returns always TRUE
+        */
+       public function canHandleRequest() {
+               return TRUE;
+       }
+
+       /**
+        * Returns the priority - how eager the handler is to actually handle the request.
+        *
+        * @return int The priority of the request handler.
+        */
+       public function getPriority() {
+               return 20;
+       }
+}
diff --git a/typo3/sysext/install/Classes/RequestHandler.php b/typo3/sysext/install/Classes/RequestHandler.php
deleted file mode 100644 (file)
index 007d511..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Core\RequestHandlerInterface;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Default request handler for all requests inside the TYPO3 Install Tool, which does a simple hardcoded
- * dispatching to a controller based on the get/post variable.
- *
- * @package TYPO3\CMS\Install
- */
-class RequestHandler implements RequestHandlerInterface {
-
-       /**
-        * Instance of the current TYPO3 bootstrap
-        * @var Bootstrap
-        */
-       protected $bootstrap;
-
-       /**
-        * Constructor handing over the bootstrap
-        *
-        * @param Bootstrap $bootstrap
-        */
-       public function __construct(Bootstrap $bootstrap) {
-               $this->bootstrap = $bootstrap;
-       }
-
-       /**
-        * Handles an install tool request
-        * Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
-        *
-        * @return void
-        */
-       public function handleRequest() {
-               $getPost = GeneralUtility::_GP('install');
-               switch ($getPost['controller']) {
-                       case 'tool':
-                               $controllerClassName = Controller\ToolController::class;
-                               break;
-                       case 'ajax':
-                               $controllerClassName = Controller\AjaxController::class;
-                               break;
-                       default:
-                               $controllerClassName = Controller\StepController::class;
-               }
-               GeneralUtility::makeInstance($controllerClassName)->execute();
-       }
-
-       /**
-        * This request handler can handle any request when not in CLI mode and the install tool flag is set
-        * please note that both checks are needed, as when in "failsafe" mode, the TYPO3_REQUESTTYPE is not
-        * necessarily set at this point.
-        *
-        * @return bool Returns TRUE if the request is in Install Tool mode, otherwise FALSE
-        */
-       public function canHandleRequest() {
-               return defined('TYPO3_enterInstallScript') || (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL);
-       }
-
-       /**
-        * Returns the priority - how eager the handler is to actually handle the request.
-        *
-        * @return int The priority of the request handler.
-        */
-       public function getPriority() {
-               return 20;
-       }
-}
index 32eb05d..8ffb386 100644 (file)
@@ -102,9 +102,8 @@ if (version_compare(PHP_VERSION, '5.5.0', '<')) {
        die('TYPO3 CMS requires PHP 5.5 or above');
 }
 
-define('TYPO3_MODE', 'BE');
-define('TYPO3_enterInstallScript', '1');
-
-// Bootstrap bare minimum: class loader, LocalConfiguration, but no extensions and such
-require __DIR__ . '/../../core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/sysext/install/Start/')->shutdown();
+// set up bare minimum application: class loader, LocalConfiguration, but no extensions and such
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/../../../contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Install\Http\Application($classLoader))->run();
+});
index 6135aa2..34e4552 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'The entry point to data handling via DataHandler was moved to an own module. Please use BackendUtility::getModuleUrl(\'tce_db\') to link to tce_db.php / DataHandler. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
+               $simpleDataHandlerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\SimpleDataHandlerController::class);
 
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'The entry point to data handling via DataHandler was moved to an own module. Please use BackendUtility::getModuleUrl(\'tce_db\') to link to tce_db.php / DataHandler. This script will be removed in TYPO3 CMS 8.'
-);
-
-$simpleDataHandlerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\SimpleDataHandlerController::class);
-
-$formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
-if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
-       $simpleDataHandlerController->initClipboard();
-       $simpleDataHandlerController->main();
-}
-$simpleDataHandlerController->finish();
+               $formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
+               if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
+                       $simpleDataHandlerController->initClipboard();
+                       $simpleDataHandlerController->main();
+               }
+               $simpleDataHandlerController->finish();
+       });
+});
index c4c12d7..f521ef1 100644 (file)
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-define('TYPO3_MODE', 'BE');
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'File handling entry point was moved an own module. Please use BackendUtility::getModuleUrl(\'tce_file\') to link to tce_file.php. This script will be removed in TYPO3 CMS 8.'
+               );
 
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
+               $fileController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\File\FileController::class);
 
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'File handling entry point was moved an own module. Please use BackendUtility::getModuleUrl(\'tce_file\') to link to tce_file.php. This script will be removed in TYPO3 CMS 8.'
-);
+               $formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
+               if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
+                       $fileController->main();
+               }
 
-$fileController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\File\FileController::class);
-
-$formprotection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
-if ($formprotection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('formToken'), 'tceAction')) {
-       $fileController->main();
-}
-
-$fileController->finish();
+               $fileController->finish();
+       });
+});
index 4a71544..e894813 100644 (file)
  * @author René Fritz <r.fritz@colorcube.de>
  * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use the corresponding Resource objects and Processing functionality
  */
-
-define('TYPO3_MODE', 'BE');
-
-require __DIR__ . '/sysext/core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->run('typo3/');
-
-\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
-       'thumbs.php is no longer in use, please use the corresponding Resource objects to generate a preview functionality for thumbnails.'
-);
-$GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\View\ThumbnailView::class);
-$GLOBALS['SOBE']->init();
-$GLOBALS['SOBE']->main();
+call_user_func(function() {
+       $classLoader = require __DIR__ . '/contrib/vendor/autoload.php';
+       (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'thumbs.php is no longer in use, please use the corresponding Resource objects to generate a preview functionality for thumbnails.'
+               );
+               $GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\View\ThumbnailView::class);
+               $GLOBALS['SOBE']->init();
+               $GLOBALS['SOBE']->main();
+       });
+});