Commit a7bade17 authored by Benni Mack's avatar Benni Mack
Browse files

[!!!][TASK] Remove TypoScript option addQueryString.method

The option typolink.addQueryString.method only has either "GET"
or nothing (using $_SERVER[QUERY_PARAMS]) as possibility.

In order to effectively make use of PSR-7 Requests and better
routing capabilities, the "GET" method is preferred, making
the whole option obsolete, and removing it.

All related Fluid arguments and Extbase UriBuilder
methods are deprecated.

Resolves: #93041
Releases: master
Change-Id: I286fdf08548f224f5e4287ad36b43b2d79a669b8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67000


Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent d66d7f68
.. include:: ../../Includes.txt
=================================================================
Breaking: #93041 - Remove TypoScript option addQueryString.method
=================================================================
See :issue:`93041`
Description
===========
The TypoScript option :typoscript:`addQueryString.method` has been removed.
If omitted, this added all parameters from the PHP `$_SERVER[QUERY_STRING]`
value, which was used heavily in PHP 3 / PHP 4 times, instead of the more
"modern" `$_GET` parameters, which was set via `addQueryString.method = GET`.
However, the latter solution was / is the default for working in PSR-7
requests, and with routing. The option itself is removed, in order to
have TYPO3 use the same values throughout TYPO3 Core, making `method = GET`
the default and thus, the only option.
To further streamline TYPO3's source code, the underlying PHP method
:php:`ContentObjectRenderer->getQueryArguments()` now only accepts exactly
one argument.
All Fluid arguments related to that setting, or Extbase UriBuilder methods
do not change any behavior anymore related to building an Uri.
Impact
======
Calling :php:`UriBuilder->setAddQueryStringMethod()` will trigger a
deprecation notice.
Calling :php:`ContentObjectRenderer->getQueryArguments()` with more
than one argument will have no effect anymore.
Setting the TypoScript option :typoscript:`addQueryString.method` will
have no effect anymore.
Using the :html:`addQueryStringMethod` argument in the following
ViewHelpers will trigger a deprecation notice:
* :html:`<f:form>`
* :html:`<f:link.action>`
* :html:`<f:link.page>`
* :html:`<f:link.typolink>`
* :html:`<f:uri.action>`
* :html:`<f:uri.page>`
* :html:`<f:uri.typolink>`
Affected Installations
======================
Any TYPO3 installation
* with extensions calling Extbase's :php:`UriBuilder->setAddQueryStringMethod()`
method
* with extensions calling :php:`ContentObjectRenderer->getQueryArguments()`
with more then one argument
* with custom templates setting the :html:`addQueryStringMethod` argument
in Fluid using one of the mentioned ViewHelper.
Migration
=========
Remove any usages within the Fluid templates or Extension code.
.. index:: Frontend, TypoScript, FullyScanned, ext:frontend
......@@ -90,11 +90,6 @@ class UriBuilder
*/
protected $addQueryString = false;
/**
* @var string
*/
protected $addQueryStringMethod = '';
/**
* @var array
*/
......@@ -359,19 +354,10 @@ class UriBuilder
*/
public function setAddQueryStringMethod(string $addQueryStringMethod): UriBuilder
{
$this->addQueryStringMethod = $addQueryStringMethod;
trigger_error('Calling UriBuilder->setAddQueryStringMethod() has no effect anymore and will be removed in TYPO3 v12. Remove any call in your custom code, as it will result in a fatal error.', E_USER_DEPRECATED);
return $this;
}
/**
* @return string
* @internal
*/
public function getAddQueryStringMethod(): string
{
return $this->addQueryStringMethod;
}
/**
* A list of arguments to be excluded from the query parameters
* Only active if addQueryString is set
......@@ -528,7 +514,6 @@ class UriBuilder
$this->language = null;
$this->createAbsoluteUri = false;
$this->addQueryString = false;
$this->addQueryStringMethod = '';
$this->argumentsToBeExcludedFromQueryString = [];
$this->linkAccessRestrictedPages = false;
$this->targetPageUid = null;
......@@ -657,12 +642,7 @@ class UriBuilder
{
$arguments = [];
if ($this->addQueryString === true) {
if ($this->addQueryStringMethod === '' || $this->addQueryStringMethod === '0' || $this->addQueryStringMethod === 'GET') {
$arguments = GeneralUtility::_GET();
} else {
// Explode GET vars recursively
parse_str(GeneralUtility::getIndpEnv('QUERY_STRING'), $arguments);
}
$arguments = GeneralUtility::_GET();
foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
$argumentArrayToBeExcluded = [];
parse_str($argumentToBeExcluded, $argumentArrayToBeExcluded);
......@@ -757,9 +737,6 @@ class UriBuilder
'exclude' => implode(',', $this->argumentsToBeExcludedFromQueryString)
];
}
if ($this->addQueryStringMethod !== '') {
$typolinkConfiguration['addQueryString.']['method'] = $this->addQueryStringMethod;
}
}
if ($this->language !== null) {
$typolinkConfiguration['language'] = $this->language;
......
......@@ -108,7 +108,6 @@ class UriBuilderTest extends UnitTestCase
->setAbsoluteUriScheme('https')
->setAddQueryString(true)
->setArgumentsToBeExcludedFromQueryString(['test' => 'addQueryStringExcludeArguments'])
->setAddQueryStringMethod('GET')
->setArgumentPrefix('testArgumentPrefix')
->setLinkAccessRestrictedPages(true)
->setTargetPageUid(123)
......@@ -121,7 +120,6 @@ class UriBuilderTest extends UnitTestCase
self::assertEquals('https', $this->uriBuilder->getAbsoluteUriScheme());
self::assertTrue($this->uriBuilder->getAddQueryString());
self::assertEquals(['test' => 'addQueryStringExcludeArguments'], $this->uriBuilder->getArgumentsToBeExcludedFromQueryString());
self::assertEquals('GET', $this->uriBuilder->getAddQueryStringMethod());
self::assertEquals('testArgumentPrefix', $this->uriBuilder->getArgumentPrefix());
self::assertTrue($this->uriBuilder->getLinkAccessRestrictedPages());
self::assertEquals(123, $this->uriBuilder->getTargetPageUid());
......@@ -212,23 +210,6 @@ class UriBuilderTest extends UnitTestCase
$_GET['foo'] = 'bar';
$_POST = [];
$this->uriBuilder->setAddQueryString(true);
$this->uriBuilder->setAddQueryStringMethod('GET');
$expectedResult = '/typo3/index.php?route=%2Ftest%2FPath&token=dummyToken&id=pageId&foo=bar';
$actualResult = $this->uriBuilder->buildBackendUri();
self::assertEquals($expectedResult, $actualResult);
}
/**
* @test
*/
public function buildBackendUriKeepsQueryParametersIfAddQueryStringMethodIsNotSet()
{
$_GET['route'] = '/test/Path';
$_GET['id'] = 'pageId';
$_GET['foo'] = 'bar';
$_POST = [];
$_POST['foo2'] = 'bar2';
$this->uriBuilder->setAddQueryString(true);
$expectedResult = '/typo3/index.php?route=%2Ftest%2FPath&token=dummyToken&id=pageId&foo=bar';
$actualResult = $this->uriBuilder->buildBackendUri();
self::assertEquals($expectedResult, $actualResult);
......@@ -310,7 +291,6 @@ class UriBuilderTest extends UnitTestCase
{
$_GET = array_replace_recursive($_GET, $parameters);
$this->uriBuilder->setAddQueryString(true);
$this->uriBuilder->setAddQueryStringMethod('GET');
$this->uriBuilder->setArgumentsToBeExcludedFromQueryString($excluded);
$actualResult = $this->uriBuilder->buildBackendUri();
self::assertEquals($expected, $actualResult);
......@@ -478,7 +458,6 @@ class UriBuilderTest extends UnitTestCase
->setFormat('someFormat')
->setCreateAbsoluteUri(true)
->setAddQueryString(true)
->setAddQueryStringMethod('test')
->setArgumentsToBeExcludedFromQueryString(['test' => 'addQueryStringExcludeArguments'])
->setLinkAccessRestrictedPages(true)
->setTargetPageUid(123)
......@@ -495,7 +474,6 @@ class UriBuilderTest extends UnitTestCase
self::assertFalse($this->uriBuilder->getCreateAbsoluteUri());
self::assertFalse($this->uriBuilder->getAddQueryString());
self::assertEquals([], $this->uriBuilder->getArgumentsToBeExcludedFromQueryString());
self::assertEquals('', $this->uriBuilder->getAddQueryStringMethod());
self::assertEquals('', $this->uriBuilder->getArgumentPrefix());
self::assertFalse($this->uriBuilder->getLinkAccessRestrictedPages());
self::assertNull($this->uriBuilder->getTargetPageUid());
......@@ -552,19 +530,6 @@ class UriBuilderTest extends UnitTestCase
self::assertEquals($expectedConfiguration, $actualConfiguration);
}
/**
* @test
*/
public function buildTypolinkConfigurationProperlySetsAddQueryStringMethod()
{
$this->uriBuilder->setTargetPageUid(123);
$this->uriBuilder->setAddQueryString(true);
$this->uriBuilder->setAddQueryStringMethod('GET');
$expectedConfiguration = ['parameter' => 123, 'addQueryString' => 1, 'addQueryString.' => ['method' => 'GET']];
$actualConfiguration = $this->uriBuilder->_call('buildTypolinkConfiguration');
self::assertEquals($expectedConfiguration, $actualConfiguration);
}
/**
* @test
*/
......
......@@ -132,7 +132,7 @@ class FormViewHelper extends AbstractFormViewHelper
$this->registerArgument('absolute', 'bool', 'If set, an absolute action URI is rendered (only active if $actionUri is not set)', false, false);
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the action URI (only active if $actionUri is not set)', false, false);
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the action URI. Only active if $addQueryString = TRUE and $actionUri is not set', false, []);
$this->registerArgument('addQueryStringMethod', 'string', 'Method to use when keeping query parameters (only active if $actionUri is not set)', false, 'GET');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
$this->registerArgument('fieldNamePrefix', 'string', 'Prefix that will be added to all field names within this form. If not set the prefix will be tx_yourExtension_plugin');
$this->registerArgument('actionUri', 'string', 'can be used to overwrite the "action" attribute of the form tag');
$this->registerArgument('objectName', 'string', 'name of the object that is bound to this form. If this argument is not specified, the name attribute of this form is used to determine the FormObjectName');
......@@ -203,6 +203,9 @@ class FormViewHelper extends AbstractFormViewHelper
if ($this->hasArgument('actionUri')) {
$formActionUri = $this->arguments['actionUri'];
} else {
if (isset($this->arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:form> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$uriBuilder = $this->renderingContext->getUriBuilder();
$uriBuilder
->reset()
......@@ -216,11 +219,6 @@ class FormViewHelper extends AbstractFormViewHelper
->setFormat($this->arguments['format'] ?? '')
;
$addQueryStringMethod = $this->arguments['addQueryStringMethod'] ?? null;
if (is_string($addQueryStringMethod)) {
$uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
}
$pageUid = (int)($this->arguments['pageUid'] ?? 0);
if ($pageUid > 0) {
$uriBuilder->setTargetPageUid($pageUid);
......
......@@ -67,7 +67,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
$this->registerArgument('absolute', 'bool', 'If set, the URI of the rendered link is absolute');
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI');
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'Arguments to be removed from the URI. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
$this->registerArgument('arguments', 'array', 'Arguments for the controller action, associative array');
}
......@@ -76,6 +76,9 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
*/
public function render()
{
if (isset($this->arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:link.action> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$action = $this->arguments['action'];
$controller = $this->arguments['controller'];
$extensionName = $this->arguments['extensionName'];
......@@ -90,7 +93,6 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
$absolute = (bool)$this->arguments['absolute'];
$addQueryString = (bool)$this->arguments['addQueryString'];
$argumentsToBeExcludedFromQueryString = (array)$this->arguments['argumentsToBeExcludedFromQueryString'];
$addQueryStringMethod = $this->arguments['addQueryStringMethod'];
$parameters = $this->arguments['arguments'];
/** @var UriBuilder $uriBuilder */
$uriBuilder = $this->renderingContext->getUriBuilder();
......@@ -111,10 +113,6 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
$uriBuilder->setTargetPageUid((int)$pageUid);
}
if (is_string($addQueryStringMethod)) {
$uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
}
$uri = $uriBuilder->uriFor($action, $parameters, $controller, $extensionName, $pluginName);
if ($uri === '') {
return $this->renderChildren();
......
......@@ -90,7 +90,7 @@ class PageViewHelper extends AbstractTagBasedViewHelper
$this->registerArgument('absolute', 'bool', 'If set, the URI of the rendered link is absolute');
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI');
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'Arguments to be removed from the URI. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
}
/**
......@@ -98,6 +98,9 @@ class PageViewHelper extends AbstractTagBasedViewHelper
*/
public function render()
{
if (isset($this->arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:link.page> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$pageUid = isset($this->arguments['pageUid']) ? (int)$this->arguments['pageUid'] : null;
$pageType = isset($this->arguments['pageType']) ? (int)$this->arguments['pageType'] : 0;
$noCache = isset($this->arguments['noCache']) ? (bool)$this->arguments['noCache'] : false;
......@@ -108,7 +111,6 @@ class PageViewHelper extends AbstractTagBasedViewHelper
$absolute = isset($this->arguments['absolute']) ? (bool)$this->arguments['absolute'] : false;
$addQueryString = isset($this->arguments['addQueryString']) ? (bool)$this->arguments['addQueryString'] : false;
$argumentsToBeExcludedFromQueryString = isset($this->arguments['argumentsToBeExcludedFromQueryString']) ? (array)$this->arguments['argumentsToBeExcludedFromQueryString'] : [];
$addQueryStringMethod = $this->arguments['addQueryStringMethod'] ?? null;
/** @var UriBuilder $uriBuilder */
$uriBuilder = $this->renderingContext->getUriBuilder();
$uriBuilder->reset()
......@@ -127,10 +129,6 @@ class PageViewHelper extends AbstractTagBasedViewHelper
$uriBuilder->setTargetPageUid((int)$pageUid);
}
if (is_string($addQueryStringMethod)) {
$uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
}
$uri = $uriBuilder->build();
if ($uri !== '') {
$this->tag->addAttribute('href', $uri);
......
......@@ -96,7 +96,7 @@ class TypolinkViewHelper extends AbstractViewHelper
$this->registerArgument('additionalParams', 'string', 'Additional query parameters to be attached to the resulting URL', false, '');
$this->registerArgument('additionalAttributes', 'array', 'Additional tag attributes to be added directly to the resulting HTML tag', false, []);
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URL', false, false);
$this->registerArgument('addQueryStringMethod', 'string', 'Method to use when keeping query parameters (only active if addQueryString is set)', false, 'GET');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
$this->registerArgument('addQueryStringExclude', 'string', 'Define parameters to be excluded from the query string (only active if addQueryString is set)', false, '');
$this->registerArgument('absolute', 'bool', 'Ensure the resulting URL is an absolute URL', false, false);
$this->registerArgument('parts-as', 'string', 'Variable name containing typoLink parts (if any)', false, 'typoLinkParts');
......@@ -139,8 +139,10 @@ class TypolinkViewHelper extends AbstractViewHelper
protected static function invokeContentObjectRenderer(array $arguments, string $typoLinkParameter, string $content): string
{
if (isset($arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:link.typolink> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$addQueryString = $arguments['addQueryString'] ?? false;
$addQueryStringMethod = $arguments['addQueryStringMethod'] ?? 'GET';
$addQueryStringExclude = $arguments['addQueryStringExclude'] ?? '';
$absolute = $arguments['absolute'] ?? false;
$aTagParams = static::serializeTagParameters($arguments);
......@@ -156,7 +158,6 @@ class TypolinkViewHelper extends AbstractViewHelper
if ($addQueryString) {
$instructions['addQueryString'] = $addQueryString;
$instructions['addQueryString.'] = [
'method' => $addQueryStringMethod,
'exclude' => $addQueryStringExclude,
];
}
......
......@@ -57,7 +57,7 @@ class ActionViewHelper extends AbstractViewHelper
$this->registerArgument('absolute', 'bool', 'If set, an absolute URI is rendered', false, false);
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI', false, false);
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
$this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
}
/**
......@@ -68,6 +68,9 @@ class ActionViewHelper extends AbstractViewHelper
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (isset($arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:uri.action> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
/** @var int $pageUid */
$pageUid = $arguments['pageUid'] ?? 0;
/** @var int $pageType */
......@@ -88,8 +91,6 @@ class ActionViewHelper extends AbstractViewHelper
$addQueryString = $arguments['addQueryString'] ?? false;
/** @var array|null $argumentsToBeExcludedFromQueryString */
$argumentsToBeExcludedFromQueryString = $arguments['argumentsToBeExcludedFromQueryString'] ?? null;
/** @var string $addQueryStringMethod */
$addQueryStringMethod = $arguments['addQueryStringMethod'] ?? '';
/** @var string|null $action */
$action = $arguments['action'] ?? null;
/** @var string|null $controller */
......@@ -140,10 +141,6 @@ class ActionViewHelper extends AbstractViewHelper
$uriBuilder->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
}
if ($addQueryStringMethod !== '') {
$uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
}
if ($linkAccessRestrictedPages === true) {
$uriBuilder->setLinkAccessRestrictedPages($linkAccessRestrictedPages);
}
......
......@@ -78,7 +78,7 @@ class PageViewHelper extends AbstractViewHelper
$this->registerArgument('absolute', 'bool', 'If set, the URI of the rendered link is absolute', false, false);
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI', false, false);
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
$this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
}
/**
......@@ -89,6 +89,9 @@ class PageViewHelper extends AbstractViewHelper
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (isset($arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:uri.page> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$pageUid = $arguments['pageUid'];
$additionalParams = $arguments['additionalParams'];
$pageType = $arguments['pageType'];
......@@ -99,7 +102,6 @@ class PageViewHelper extends AbstractViewHelper
$absolute = $arguments['absolute'];
$addQueryString = $arguments['addQueryString'];
$argumentsToBeExcludedFromQueryString = $arguments['argumentsToBeExcludedFromQueryString'];
$addQueryStringMethod = $arguments['addQueryStringMethod'];
$uriBuilder = $renderingContext->getUriBuilder();
$uri = $uriBuilder
......@@ -119,10 +121,6 @@ class PageViewHelper extends AbstractViewHelper
$uriBuilder->setTargetPageUid((int)$pageUid);
}
if (is_string($addQueryStringMethod)) {
$uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
}
return $uri->build();
}
}
......@@ -69,7 +69,7 @@ class TypolinkViewHelper extends AbstractViewHelper
$this->registerArgument('additionalParams', 'string', 'stdWrap.typolink additionalParams', false, '');
$this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false, null);
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URL', false, false);
$this->registerArgument('addQueryStringMethod', 'string', 'Method to use when keeping query parameters (only active if addQueryString is set)', false, 'GET');
$this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
$this->registerArgument('addQueryStringExclude', 'string', 'Define parameters to be excluded from the query string (only active if addQueryString is set)', false, '');
$this->registerArgument('absolute', 'bool', 'Ensure the resulting URL is an absolute URL', false, false);
}
......@@ -98,8 +98,10 @@ class TypolinkViewHelper extends AbstractViewHelper
protected static function invokeContentObjectRenderer(array $arguments, string $typoLinkParameter): string
{
if (isset($arguments['addQueryStringMethod'])) {
trigger_error('Using the argument "addQueryStringMethod" in <f:uri.typolink> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
}
$addQueryString = $arguments['addQueryString'] ?? false;
$addQueryStringMethod = $arguments['addQueryStringMethod'] ?? 'GET';
$addQueryStringExclude = $arguments['addQueryStringExclude'] ?? '';
$absolute = $arguments['absolute'] ?? false;
......@@ -113,7 +115,6 @@ class TypolinkViewHelper extends AbstractViewHelper
if ($addQueryString) {
$instructions['addQueryString'] = $addQueryString;
$instructions['addQueryString.'] = [
'method' => $addQueryStringMethod,
'exclude' => $addQueryStringExclude,
];
}
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:link.typolink parameter="{parameter}" addQueryString="{addQueryString}" addQueryStringMethod="{addQueryStringMethod}"
addQueryStringExclude="{addQueryStringExclude}">This is a testlink</f:link.typolink>
<f:link.typolink parameter="{parameter}" addQueryString="{addQueryString}" addQueryStringExclude="{addQueryStringExclude}">This is a testlink</f:link.typolink>
<f:link.typolink parameter="{parameter}">This is a testlink</f:link.typolink>
</html>
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:uri.typolink parameter="{parameter}" addQueryString="{addQueryString}" addQueryStringMethod="{addQueryStringMethod}"
addQueryStringExclude="{addQueryStringExclude}" />
<f:uri.typolink parameter="{parameter}" addQueryString="{addQueryString}" addQueryStringExclude="{addQueryStringExclude}" />
<f:uri.typolink parameter="{parameter}" />
</html>
......@@ -78,7 +78,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
/**
* @param mixed $parameter
* @param bool $addQueryString
* @param string $addQueryStringMethod
* @param string $addQueryStringExclude
* @param string $expected
* @param string $template
......@@ -89,7 +88,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
public function renderCreatesCorrectLink(
$parameter,
bool $addQueryString,
string $addQueryStringMethod,
string $addQueryStringExclude,
string $expected,
string $template
......@@ -100,7 +98,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'parameter' => $parameter,
'uid' => 1,
'addQueryString' => $addQueryString,
'addQueryStringMethod' => $addQueryStringMethod,
'addQueryStringExclude' => $addQueryStringExclude,
]);
self::assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render())));
......@@ -115,7 +112,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'link: default' => [
'parameter' => 1,
'addQueryString' => false,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '<a href="/en/">This is a testlink</a> <a href="/en/">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -123,7 +119,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'link: with add query string' => [
'parameter' => 1,
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '<a href="/en/?foo=bar&amp;temp=test&amp;cHash=286759dfcd3f566fa21091a0d77e9831">This is a testlink</a> <a href="/en/">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -131,7 +126,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'link: with add query string and exclude' => [
'parameter' => 1,
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => 'temp',
'expected' => '<a href="/en/?foo=bar&amp;cHash=afa4b37588ab917af3cfe2cd4464029d">This is a testlink</a> <a href="/en/">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -139,7 +133,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'uri: default' => [
'parameter' => 1,
'addQueryString' => false,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '/en/ /en/',
'template' => 'uri_typolink_viewhelper',
......@@ -147,7 +140,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'uri: with add query string' => [
'parameter' => 1,
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '/en/?foo=bar&amp;temp=test&amp;cHash=286759dfcd3f566fa21091a0d77e9831 /en/',
'template' => 'uri_typolink_viewhelper',
......@@ -155,7 +147,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
'uri: with add query string and exclude' => [
'parameter' => 1,
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => 'temp',
'expected' => '/en/?foo=bar&amp;cHash=afa4b37588ab917af3cfe2cd4464029d /en/',
'template' => 'uri_typolink_viewhelper',
......@@ -163,7 +154,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
't3://url link: default' => [
'parameter' => 't3://url?url=https://example.org?param=1&other=dude',
'addQueryString' => false,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '<a href="https://example.org?param=1">This is a testlink</a> <a href="https://example.org?param=1">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -171,7 +161,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
't3://url link: with add query string' => [
'parameter' => 't3://url?url=https://example.org?param=1&other=dude',
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => '<a href="https://example.org?param=1">This is a testlink</a> <a href="https://example.org?param=1">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -179,7 +168,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
't3://url link: with add query string and exclude' => [
'parameter' => 't3://url?url=https://example.org?param=1&other=dude',
'addQueryString' => true,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => 'temp',
'expected' => '<a href="https://example.org?param=1">This is a testlink</a> <a href="https://example.org?param=1">This is a testlink</a>',
'template' => 'link_typolink_viewhelper',
......@@ -187,7 +175,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
't3://url uri: default' => [
'parameter' => 't3://url?url=https://example.org?param=1&other=dude',
'addQueryString' => false,
'addQueryStringMethod' => 'GET',
'addQueryStringExclude' => '',
'expected' => 'https://example.org?param=1 https://example.org?param=1',
'template' => 'uri_typolink_viewhelper',
......@@ -195,7 +182,6 @@ class TypolinkViewHelperTest extends FunctionalTestCase
't3://url uri: with add query string' => [
'parameter' => 't3://url?url=https://example.org?param=1&other=dude',