diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80510-ContentObjectRenderer-URLqMark.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80510-ContentObjectRenderer-URLqMark.rst new file mode 100644 index 0000000000000000000000000000000000000000..6b67561afed66b59d18310cd81c88b356fe4abfa --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80510-ContentObjectRenderer-URLqMark.rst @@ -0,0 +1,36 @@ +.. include:: ../../Includes.txt + +===================================================== +Deprecation: #80510 - ContentObjectRenderer->URLqMark +===================================================== + +See :issue:`80510` + +Description +=========== + +The PHP method php:`ContentObjectRenderer->URLqMark()` has been marked as deprecated. It was +used to add a `?` between two strings if the first one does contain a `?` already. + +Its main purpose is to add query string parameters to a given URL. + + +Impact +====== + +Calling the method above will trigger a deprecation warning. + + +Affected Installations +====================== + +Any installation using custom extensions calling this method. + + +Migration +========= + +Implement this functionality with PHP's native php:`(strpos($haystack, '?') !== false ? '?' : '')` +one-liner directly. + +.. index:: PHP-API \ No newline at end of file diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 625ca50f5d6ac6a1606fffc8d33df56057f621d6..cdf99b7e8ef330d5d8aadd1dbff2c27ace39f2b5 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -5903,7 +5903,7 @@ class ContentObjectRenderer if (!preg_match('/^[a-z0-9.\\-]*$/i', $targetDomain)) { $targetDomain = GeneralUtility::idnaEncode($targetDomain); } - $this->lastTypoLinkUrl = $this->URLqMark($absoluteUrlScheme . '://' . $targetDomain . '/index.php?id=' . $page['uid'], $addQueryParams) . $sectionMark; + $this->lastTypoLinkUrl = $absoluteUrlScheme . '://' . $targetDomain . '/index.php?id=' . $page['uid'] . $addQueryParams . $sectionMark; } else { // Internal link or current domain's linking scheme should be used // Internal target: @@ -6947,9 +6947,11 @@ class ContentObjectRenderer * @param string $url Input URL * @param string $params URL parameters * @return string + * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, please use this functionality by yourself instead of using cObj for that */ public function URLqMark($url, $params) { + GeneralUtility::logDeprecatedFunction(); if ($params && !strstr($url, '?')) { return $url . '?' . $params; } else { diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php index 156af2b18e76f04d28cff417dfacbe4a0cb26d78..041198fb15c29d4325305acbb876e497f3cad414 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php @@ -1696,7 +1696,7 @@ abstract class AbstractMenuContentObject if (preg_match('/([0-9]+[\\s])?(([0-9]+)x([0-9]+))?(:.+)?/s', $LD['target'], $matches) || $targetIsType) { // has type? if ((int)$matches[1] || $targetIsType) { - $LD['totalURL'] = $this->parent_cObj->URLqMark($LD['totalURL'], '&type=' . ($targetIsType ?: (int)$matches[1])); + $LD['totalURL'] .= (strpos($LD['totalURL'], '?') === false ? '?' : '&') . 'type=' . ($targetIsType ?: (int)$matches[1]); $LD['target'] = $targetIsType ? '' : trim(substr($LD['target'], strlen($matches[1]) + 1)); } // Open in popup window?