#31771Wrong "targetDomain" in tslib_cObj::typolink with sys_domain records and different url sheme
Description
If you generate a link with “tslib_cObj::typolink” to a page which has a different domain, typolink() loads the matching domain from sys_domain. But if the target page has a different url scheme (set in page settings) than the current rendered page, then always the current domain will be used!
You can find this issue in line 5788-5792 in “class.tslib_content.php”:
// If no domain records are defined, use current domain:
if ($targetDomain === '' && $conf['forceAbsoluteUrl'] ||
$absoluteUrlScheme !== parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME)) {
$targetDomain = $currentDomain;
}
You have to check for a empty $targetDomain if the target-scheme is different too! Otherwise the correct targetDomain will always be overwritten with the current domain:
You can fix it with some braces to check always for a empty targetDomain:
// If no domain records are defined, use current domain:
if ($targetDomain === '' && ($conf['forceAbsoluteUrl'] ||
$absoluteUrlScheme !== parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME))) {
$targetDomain = $currentDomain;
}