aimeos / aimeos-typo3

TYPO3 e-commerce extension for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce

Home Page:https://aimeos.org/TYPO3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not use the L parameter for link generation

guelzow opened this issue · comments

When using the L parameter in the url, all FE links are pointing to the language specified in the L parameter, while the page language stays the same.

Example link with the demo shop:
https://typo3.demo.aimeos.org/demo?L=1
The FE language is still English, while the shop links point to the German product details.

When the shop uses heavy caching, there is a chance that these wrong links are cached and the customer has suddenly a different language selected.

Whet is happening in the code:
Here the initial value is taken from the url.
Here it is inserted into the uri builder.
Here the uri builder is making use of the L parameter, generating the wrong language links.

Proposed solution
Simply remove the part where the L parameter is taken from the url.

Alternative solution
I'm not really sure if there are TYPO3 9 or 10 site out there that are dependant on the L parameter to set their language and where the uri builder must be equipped with the L parameter from the outside.
So instead of simply removing this part, replacing it with this might be an alternative:

if( $request !== null && $request->hasArgument( $name ) === true ) {
    $fixed[$name] = $request->getArgument( $name );
} else {
    $fixed['L'] = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Context\Context' )->getAspect( 'language' )->getId();
}

Then again, if the uri builder does not know the current language, there is a good chance that the language aspect also has no idea.

Tobi

This should most likely have the same code as the Locale class:
https://github.com/aimeos/aimeos-typo3/blob/21.7.1/Classes/Base/Locale.php#L55-L59

Can you create a PR for the change?