Commit 7281ab4a authored by Wouter Wolters's avatar Wouter Wolters Committed by Christian Kuhn
Browse files

[TASK] Move Backend Module calls to index.php

The typo3/mod.php entrypoint is removed in favor of
checking for M in all backend requests inside the Backend
Application.

The request object from the server is now enhanced with the
information inside the application which type is now called.

Resolves: #68183
Releases: master
Change-Id: Ia51244bb1a017ac5736c1133d14066b76b3d1f72
Reviewed-on: http://review.typo3.org/41305


Reviewed-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 5f147d21
......@@ -21,5 +21,9 @@ namespace TYPO3\CMS\Backend;
*/
call_user_func(function() {
$classLoader = require __DIR__ . '/vendor/autoload.php';
(new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
(new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
'The entry point to mod.php was moved to index.php with "M" given. Please use BackendUtility::getModuleUrl(\'myModuleKey\') to link to a module. This script will be removed in TYPO3 CMS 8.'
);
});
});
......@@ -300,7 +300,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
}
/**
* Adds the correct token, if the url is a mod.php script
* Adds the correct token, if the url is a index.php script
*
* @param string $url
* @return string
......@@ -313,7 +313,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
if (isset($parameters['returnUrl'])) {
$parsedReturnUrl = parse_url($parameters['returnUrl']);
parse_str($parsedReturnUrl['query'], $returnUrlParameters);
if (strpos($parsedReturnUrl['path'], 'mod.php') !== FALSE && isset($returnUrlParameters['M'])) {
if (strpos($parsedReturnUrl['path'], 'index.php') !== FALSE && isset($returnUrlParameters['M'])) {
$module = $returnUrlParameters['M'];
$returnUrl = BackendUtility::getModuleUrl($module, $returnUrlParameters);
$parameters['returnUrl'] = $returnUrl;
......@@ -321,7 +321,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
}
}
if (strpos($parsedUrl['path'], 'mod.php') !== FALSE && isset($parameters['M'])) {
if (strpos($parsedUrl['path'], 'index.php') !== FALSE && isset($parameters['M'])) {
$module = $parameters['M'];
$url = BackendUtility::getModuleUrl($module, $parameters);
}
......
......@@ -75,6 +75,8 @@ class Application implements ApplicationInterface {
// see below when this option is set
if ($GLOBALS['TYPO3_AJAX']) {
$this->request = $this->request->withAttribute('isAjaxRequest', TRUE);
} elseif (isset($this->request->getQueryParams()['M'])) {
$this->request = $this->request->withAttribute('isModuleRequest', TRUE);
}
$this->bootstrap->configure();
......@@ -115,7 +117,7 @@ class Application implements ApplicationInterface {
// activate "AJAX" handler when called with the GET variable ajaxID
if (GeneralUtility::_GET('ajaxID') !== NULL) {
$GLOBALS['TYPO3_AJAX'] = TRUE;
} elseif (substr($currentScript, -16) === '/typo3/index.php') {
} elseif (GeneralUtility::_GET('ajaxID') === NULL && substr($currentScript, -16) === '/typo3/index.php') {
// allow backend login to work
define('TYPO3_PROCEED_IF_NO_USER', 1);
}
......
......@@ -75,7 +75,7 @@ class BackendModuleRequestHandler implements RequestHandlerInterface {
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
// Set to empty as it is not needed / always coming from typo3/index.php
$GLOBALS['BACK_PATH'] = '';
$this->backendUserAuthentication = $GLOBALS['BE_USER'];
......@@ -117,13 +117,13 @@ class BackendModuleRequestHandler implements RequestHandlerInterface {
}
/**
* This request handler can handle any backend request coming from mod.php
* This request handler can handle any backend request coming from index.php
*
* @param ServerRequestInterface $request
* @return bool
*/
public function canHandleRequest(ServerRequestInterface $request) {
return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && !empty((string)$request->getQueryParams()['M']);
return $request->getAttribute('isModuleRequest', FALSE);
}
/**
......
......@@ -21,7 +21,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* 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.
* the controller is still done inside places like 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.
*/
......
......@@ -111,9 +111,9 @@ class ModuleLoader {
*/
$this->absPathArray = $modulesArray['_PATHS'];
unset($modulesArray['_PATHS']);
// Unset the array for calling external backend module dispatchers in typo3/mod.php
// Unset the array for calling external backend module dispatchers in typo3/index.php
unset($modulesArray['_dispatcher']);
// Unset the array for calling backend modules based on external backend module dispatchers in typo3/mod.php
// Unset the array for calling backend modules based on external backend module dispatchers in typo3/index.php
unset($modulesArray['_configuration']);
$this->navigationComponents = $modulesArray['_navigationComponents'];
unset($modulesArray['_navigationComponents']);
......
......@@ -637,8 +637,8 @@ function jumpToUrl(URL) {
public function makeShortcutIcon($gvList, $setList, $modName, $motherModName = '') {
$storeUrl = $this->makeShortcutUrl($gvList, $setList);
$pathInfo = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
// Add the module identifier automatically if typo3/mod.php is used:
if (preg_match('/typo3\\/mod\\.php$/', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
// Add the module identifier automatically if typo3/index.php is used:
if (GeneralUtility::_GET('M') !== NULL && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
$storeUrl = '&M=' . $modName . $storeUrl;
}
if ((int)$motherModName === 1) {
......
......@@ -3076,7 +3076,7 @@ class BackendUtility {
if (!$script) {
$script = basename(PATH_thisScript);
}
if ($script === 'mod.php' && GeneralUtility::_GET('M')) {
if ($script === 'index.php' && GeneralUtility::_GET('M')) {
$scriptUrl = self::getModuleUrl(GeneralUtility::_GET('M'), $mainParams) . $addParams;
} else {
$scriptUrl = $script . '?' . GeneralUtility::implodeArrayForUrl('', $mainParams) . $addParams;
......@@ -3269,7 +3269,7 @@ class BackendUtility {
'M' => $moduleName,
'moduleToken' => FormProtectionFactory::get()->generateToken('moduleCall', $moduleName)
) + $urlParameters;
$url = 'mod.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters, '', TRUE, TRUE), '&');
$url = 'index.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters, '', TRUE, TRUE), '&');
if ($returnAbsoluteUrl) {
return GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . $url;
} else {
......
<?php
// Required for mod.php
$MCONF['name'] = 'browser';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
// Required for mod.php
$MCONF['name'] = 'dummy';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
// Required for mod.php
$MCONF['name'] = 'tce_file';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
// Required for mod.php
$MCONF['name'] = 'tce_db';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
//required for mod.php
$MCONF['name'] = 'file_edit';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
\ No newline at end of file
<?php
//required for mod.php
$MCONF['name'] = 'file_newfolder';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
\ No newline at end of file
<?php
// Required for mod.php
$MCONF['name'] = 'record_edit';
$MCONF['script'] = '_DISPATCH';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
//required for mod.php
$MCONF['name'] = 'record_history';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
$MCONF['access'] = '';
\ No newline at end of file
<?php
// required for mod.php
$MCONF['name'] = 'show_item';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
//required for mod.php
$MCONF['name'] = 'wizard_add';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
// required for mod.php
$MCONF['name'] = 'wizard_backend_layout';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
\ No newline at end of file
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
<?php
//required for mod.php
$MCONF['name'] = 'wizard_colorpicker';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';
$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment