Commit b18c047b authored by Anja Leichsenring's avatar Anja Leichsenring Committed by Christian Kuhn

[TASK] Replace GeneralUtility::getIndpEnv('REQUEST_URI')

If a reqest object already is around,
$request->getAttribute('normalizedParams')->getRequestUri()
can be used as a drop in replacement.
As a fallback $GLOBALS['TYPO3_REQUEST'] is almost always
available and contains the request object.

Resolves: #93178
Releases: master
Change-Id: I2bb13a54e6b8705be5783042a4f67f9735c627a3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67255Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 38b3680e
......@@ -123,7 +123,7 @@ class SiteConfigurationController
*/
protected function overviewAction(ServerRequestInterface $request): void
{
$this->configureOverViewDocHeader();
$this->configureOverViewDocHeader($request->getAttribute('normalizedParams')->getRequestUri());
$allSites = $this->siteFinder->getAllSites();
$pages = $this->getAllSitePages();
$unassignedSites = [];
......@@ -627,13 +627,15 @@ class SiteConfigurationController
/**
* Create document header buttons of "overview" action
*
* @param string $requestUri
*/
protected function configureOverViewDocHeader(): void
protected function configureOverViewDocHeader(string $requestUri): void
{
$iconFactory = $this->moduleTemplate->getIconFactory();
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$reloadButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setHref($requestUri)
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
......
......@@ -402,7 +402,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
$row['uid'] => 'edit'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri() . '#element-tt_content-' . $row['uid']
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
......
......@@ -530,7 +530,7 @@ class ModuleTemplate
trigger_error('Method makeShortcutIcon() is deprecated and will be removed in v12. Please use ShortcutButton->setArguments() instead.', E_USER_DEPRECATED);
$gvList = 'route,id,' . $gvList;
$storeUrl = $this->makeShortcutUrl($gvList, $setList);
$pathInfo = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
$pathInfo = parse_url($GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri());
// Fallback for alt_mod. We still pass in the old xMOD... stuff,
// but TBE_MODULES only knows about "record_edit".
// We still need to pass the xMOD name to createShortcut below,
......
......@@ -284,7 +284,7 @@ class PagePositionMap
'positionPid' => $pid,
'newPageId' => $newPagePID,
'cmd' => 'crPage',
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $this->R_URI
]
);
return (string)$url;
......
......@@ -2385,14 +2385,14 @@ class BackendUtility
* Returns a URL with a command to TYPO3 Datahandler
*
* @param string $parameters Set of GET params to send. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World
* @param string $redirectUrl Redirect URL, default is to use GeneralUtility::getIndpEnv('REQUEST_URI')
* @param string $redirectUrl Redirect URL, default is to use $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
* @return string
*/
public static function getLinkToDataHandlerAction($parameters, $redirectUrl = '')
{
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('tce_db') . $parameters . '&redirect=';
$url .= rawurlencode($redirectUrl ?: GeneralUtility::getIndpEnv('REQUEST_URI'));
$url .= rawurlencode($redirectUrl ?: $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri());
return $url;
}
......
......@@ -155,7 +155,7 @@ class GridColumn extends AbstractGridObject
);
$editParam = '&edit[tt_content][' . implode(',', $this->getAllContainedItemUids()) . ']=edit' . $pageTitleParamForAltDoc;
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return $uriBuilder->buildUriFromRoute('record_edit') . $editParam . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
return $uriBuilder->buildUriFromRoute('record_edit') . $editParam . '&returnUrl=' . rawurlencode($GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri());
}
public function getNewContentUrl(): string
......@@ -169,7 +169,7 @@ class GridColumn extends AbstractGridObject
'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId(),
'colPos' => $this->getColumnNumber(),
'uid_pid' => $pageId,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = BackendUtility::getPagesTSconfig($pageId)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
......@@ -186,7 +186,7 @@ class GridColumn extends AbstractGridObject
'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId()
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = 'record_edit';
}
......
......@@ -271,7 +271,7 @@ class GridColumnItem extends AbstractGridObject
'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId(),
'colPos' => $this->column->getColumnNumber(),
'uid_pid' => -$this->record['uid'],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = BackendUtility::getPagesTSconfig($pageId)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
......@@ -282,7 +282,7 @@ class GridColumnItem extends AbstractGridObject
-$this->record['uid'] => 'new'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = 'record_edit';
}
......@@ -334,7 +334,7 @@ class GridColumnItem extends AbstractGridObject
$this->record['uid'] => 'edit',
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $this->record['uid'],
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri() . '#element-tt_content-' . $this->record['uid'],
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters) . '#element-tt_content-' . $this->record['uid'];
......
......@@ -131,7 +131,7 @@ class LanguageColumn extends AbstractGridObject
'sys_language_uid' => $this->context->getSiteLanguage()->getLanguageId()
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
......
......@@ -340,7 +340,7 @@ class PageLayoutContext
// which, when finished editing should return back to the current page (returnUrl)
$parameters = [
'justLocalized' => 'pages:' . $id . ':' . $languageUid,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters);
......
......@@ -357,7 +357,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language_uid' => $lP,
'colPos' => $columnId,
'uid_pid' => $id,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = BackendUtility::getPagesTSconfig($id)['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
......@@ -375,7 +375,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language_uid' => $lP
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
......@@ -465,7 +465,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language_uid' => $row['sys_language_uid'],
'colPos' => $row['colPos'],
'uid_pid' => -$row['uid'],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$routeName = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['newContentElementWizard.']['override']
?? 'new_content_element_wizard';
......@@ -477,7 +477,7 @@ class PageLayoutView implements LoggerAwareInterface
-$row['uid'] => 'new'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
}
......@@ -771,7 +771,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language_uid' => $languageId
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
if ($this->getBackendUser()->check('tables_modify', 'pages')) {
......@@ -812,7 +812,7 @@ class PageLayoutView implements LoggerAwareInterface
$this->id => 'edit'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
if ($this->getBackendUser()->check('tables_modify', 'pages')) {
......@@ -938,7 +938,7 @@ class PageLayoutView implements LoggerAwareInterface
$icons = '';
// Edit whole of column:
if ($editParams && $this->hasContentModificationAndAccessPermissions() && $this->getBackendUser()->checkLanguageAccess(0)) {
$link = $this->uriBuilder->buildUriFromRoute('record_edit') . $editParams . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
$link = $this->uriBuilder->buildUriFromRoute('record_edit') . $editParams . '&returnUrl=' . rawurlencode($GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri());
$icons = '<a href="' . htmlspecialchars($link) . '" title="'
. htmlspecialchars($this->getLanguageService()->getLL('editColumn')) . '">'
. $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
......@@ -1039,7 +1039,7 @@ class PageLayoutView implements LoggerAwareInterface
$row['uid'] => 'edit'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'],
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri() . '#element-tt_content-' . $row['uid'],
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters) . '#element-tt_content-' . $row['uid'];
......@@ -1538,7 +1538,7 @@ class PageLayoutView implements LoggerAwareInterface
$row['uid'] => 'edit'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri() . '#element-tt_content-' . $row['uid']
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
return '<a href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $str . '</a>';
......@@ -1597,7 +1597,7 @@ class PageLayoutView implements LoggerAwareInterface
// which, when finished editing should return back to the current page (returnUrl)
$parameters = [
'justLocalized' => 'pages:' . $id . ':' . $languageUid,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$redirectUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $parameters);
$targetUrl = BackendUtility::getLinkToDataHandlerAction(
......
......@@ -84,7 +84,7 @@ class EditRecordViewHelper extends AbstractTagBasedViewHelper
throw new \InvalidArgumentException('Uid must be a positive integer, ' . $this->arguments['uid'] . ' given.', 1526127158);
}
if (empty($this->arguments['returnUrl'])) {
$this->arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$this->arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -125,7 +125,7 @@ class NewRecordViewHelper extends AbstractTagBasedViewHelper
}
if (empty($this->arguments['returnUrl'])) {
$this->arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$this->arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -19,7 +19,6 @@ namespace TYPO3\CMS\Backend\ViewHelpers\ModuleLayout;
use TYPO3\CMS\Backend\Template\Components\Menu\Menu;
use TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
......@@ -98,6 +97,6 @@ class MenuItemViewHelper extends AbstractViewHelper
*/
protected static function isCurrentUri(string $uri): bool
{
return GeneralUtility::getIndpEnv('REQUEST_URI') === $uri;
return $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri() === $uri;
}
}
......@@ -73,7 +73,7 @@ class ModuleLinkViewHelper extends AbstractViewHelper
ArrayUtility::mergeRecursiveWithOverrule($parameters, GeneralUtility::explodeUrl2Array($arguments['query']));
}
if ($arguments['currentUrlParameterName'] !== null) {
$parameters[$arguments['currentUrlParameterName']] = GeneralUtility::getIndpEnv('REQUEST_URI');
$parameters[$arguments['currentUrlParameterName']] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
return (string)$uriBuilder->buildUriFromRoute($arguments['route'], $parameters);
......
......@@ -72,7 +72,7 @@ class EditRecordViewHelper extends AbstractViewHelper
throw new \InvalidArgumentException('Uid must be a positive integer, ' . $arguments['uid'] . ' given.', 1526128259);
}
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -100,7 +100,7 @@ class NewRecordViewHelper extends AbstractTagBasedViewHelper
}
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -21,6 +21,9 @@ use Prophecy\Argument;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
......@@ -79,6 +82,10 @@ class PageLayoutViewTest extends FunctionalTestCase
]);
$this->subject = $this->getAccessibleMock(PageLayoutView::class, ['dummy'], [$eventDispatcher->reveal()]);
$this->subject->_set('siteLanguages', $site->getLanguages());
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest('https://www.example.com/'))
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('normalizedParams', new NormalizedParams([], [], '', ''));
}
/**
......
......@@ -17,6 +17,9 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Link;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
......@@ -26,6 +29,14 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class EditRecordViewHelperTest extends FunctionalTestCase
{
public function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest('https://www.example.com/'))
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('normalizedParams', new NormalizedParams([], [], '', ''));
}
/**
* @test
*/
......
......@@ -17,6 +17,9 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Link;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
......@@ -26,6 +29,14 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class NewRecordViewHelperTest extends FunctionalTestCase
{
public function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest('https://www.example.com/'))
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('normalizedParams', new NormalizedParams([], [], '', ''));
}
/**
* @test
*/
......
......@@ -17,6 +17,9 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Uri;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
......@@ -26,6 +29,14 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class EditRecordViewHelperTest extends FunctionalTestCase
{
public function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest('https://www.example.com/'))
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('normalizedParams', new NormalizedParams([], [], '', ''));
}
/**
* @test
*/
......
......@@ -17,6 +17,9 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Uri;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
......@@ -26,6 +29,14 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class NewRecordViewHelperTest extends FunctionalTestCase
{
public function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest('https://www.example.com/'))
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('normalizedParams', new NormalizedParams([], [], '', ''));
}
/**
* @test
*/
......
......@@ -697,7 +697,7 @@ class QueryView
$row['uid'] => 'edit'
]
],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
. HttpUtility::buildQueryString(['SET' => (array)GeneralUtility::_POST('SET')], '&')
]);
$out .= '<a class="btn btn-default" href="' . htmlspecialchars($url) . '">'
......
......@@ -51,7 +51,7 @@ class EditFileContentViewHelper extends AbstractViewHelper
public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
/** @var \TYPO3\CMS\Core\Resource\AbstractFile $file */
......
......@@ -50,7 +50,7 @@ class RenameFileViewHelper extends AbstractViewHelper
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
/** @var \TYPO3\CMS\Core\Resource\AbstractFile $file */
......
......@@ -50,7 +50,7 @@ class ReplaceFileViewHelper extends AbstractViewHelper
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
$arguments['returnUrl'] = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri();
}
/** @var \TYPO3\CMS\Core\Resource\AbstractFile $file */
......
......@@ -469,7 +469,7 @@ class FormManagerController extends AbstractBackendController
// Reload
$reloadButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setHref($GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri())
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
......
......@@ -6490,6 +6490,9 @@ class ContentObjectRenderer implements LoggerAwareInterface
*/
protected function getEnvironmentVariable($key)
{
if ($key === 'REQUEST_URI') {
return $this->getRequest()->getAttribute('normalizedParams')->getRequestUri();
}
return GeneralUtility::getIndpEnv($key);
}
......
......@@ -908,7 +908,7 @@ class AbstractPlugin
'beforeLastTag' => 1,
'iconTitle' => $title
], $oConf);
$content = $this->cObj->editIcons($content, $tablename . ':' . $fields, $conf, $tablename . ':' . $row['uid'], $row, '&viewUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')));
$content = $this->cObj->editIcons($content, $tablename . ':' . $fields, $conf, $tablename . ':' . $row['uid'], $row, '&viewUrl=' . rawurlencode($this->cObj->getRequest()->getAttribute('normalizedParams')->getRequestUri()));
}
return $content;
}
......
......@@ -116,7 +116,7 @@ class InfoPageTyposcriptConfigController
]
],
'columnsOnly' => 'TSconfig,tsconfig_includes',
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$line['editIcon'] = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$line['editTitle'] = 'editTSconfig';
......@@ -137,7 +137,7 @@ class InfoPageTyposcriptConfigController
]
],
'columnsOnly' => 'TSconfig,tsconfig_includes',
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getRequestUri()
];
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$editIcon = htmlspecialchars($url);
......
......@@ -105,7 +105,9 @@ class PageInformationController
. BackendUtility::cshItem('_MOD_web_info', 'func_' . $this->pObj->MOD_SETTINGS['pages'], '', '<span class="btn btn-default btn-sm">|</span>')
. '</div>'
. '</div>'
. $this->getTable_pages($this->id, (int)$this->pObj->MOD_SETTINGS['depth']);
// Using $GLOBALS['TYPO3_REQUEST'] since $request is not available at this point
// @todo: Refactor mess and have $request available
. $this->getTable_pages($this->id, (int)$this->pObj->MOD_SETTINGS['depth'], $GLOBALS['TYPO3_REQUEST']);
// Additional footer content
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'] ?? [] as $hook) {
......@@ -199,9 +201,11 @@ class PageInformationController
*
* @param int $id Page id
* @param int $depth
* @param ServerRequestInterface $request
* @return string HTML for the listing
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
protected function getTable_pages($id, int $depth = 0)
protected function getTable_pages($id, int $depth = 0, ServerRequestInterface $request)
{
$out = '';
$lang = $this->getLanguageService();
......@@ -229,13 +233,13 @@ class PageInformationController
if ($this->getBackendUser()->doesUserHaveAccess($row, Permission::PAGE_EDIT) && $row['uid'] > 0) {
$editUids[] = $row['uid'];
}
$out .= $this->pages_drawItem($row, $this->fieldArray);
$out .= $this->pages_drawItem($row, $this->fieldArray, $request);
// Traverse all pages selected:
foreach ($theRows as $sRow) {
if ($this->getBackendUser()->doesUserHaveAccess($sRow, Permission::PAGE_EDIT)) {
$editUids[] = $sRow['uid'];
}
$out .= $this->pages_drawItem($sRow, $this->fieldArray);
$out .= $this->pages_drawItem($sRow, $this->fieldArray, $request);
}
// Header line is drawn
$theData = [];
......@@ -257,7 +261,7 @@ class PageInformationController
]
],
'columnsOnly' => $field,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
......@@ -374,9 +378,11 @@ class PageInformationController
*
* @param array $row Record array
* @param array $fieldArr Field list
* @param ServerRequestInterface $request
* @return string HTML for the item
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/