Open mbrodala opened 7 years ago
Hi, I face the same problem on different cases.
In fact it's the addQueryString
option for typolink is broken using cooluri since the introduction of GeneralUtility runtime cache.
Unfortunatly the addQueryStringMethod parameter is not always available to use (ex: f:form viewhelper).
I tried @mbrodala's solution and used directly $_SERVER['QUERY_STRING']
in the CoolUri->decodeSpURL_createQueryStringParam()
and all broken cases are fixed.
Are you ok for a PR ?
When generating e.g. language menus with
addQueryString
, current internal query string arguments are not taken into account.This can easily be reproduced by opening e.g. a news record and having a look at the URI pointing to translations of that news record: the URI will point to the detail page instead of the specific record.
We currently use the following to map the news parameter within an URI:
After some debugging we found out that it's related to
$_SERVER['QUERY_STRING']
:When processing a request, CoolURI first retrieves this value through
GeneralUtility::getIndpEnv('QUERY_STRING')
, and processes it. At this point$_SERVER['QUERY_STRING']
is still empty and only updated afterwards.However, there is a runtime cache for
GeneralUtility::getIndpEnv()
since TYPO3 7.5, thus every subsequent call toGeneralUtility::getIndpEnv('QUERY_STRING')
will return the original empty value.And this brings us back to the menus: if you set
addQueryString = 1
,AbstractMenuContentObject::prepareMenuItemsForLanguageMenu()
calls theContentObjectRenderer::getQueryArguments()
method which usesGeneralUtility::getIndpEnv('QUERY_STRING')
if no method was specified (default) and thus gets the initial empty value.To finalize everything: CoolURI should directly access
$_SERVER['QUERY_STRING]
and thus bypass the runtime cache ofGeneralUtility::getIndpEnv()
. There is a methodGeneralUtility::flushInternalRuntimeCaches()
but it's marked as@internal
and should thus not be used here.Our temporary workaround to fix the language menus is adding
addQueryStringMethod = GET
which then uses the uncached raw GET parameters.