Bug #31771

Wrong "targetDomain" in tslib_cObj::typolink with sys_domain records and different url sheme

Added by Jaume Prat almost 11 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
Start date:
2011-11-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
5.3
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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;
}
#1

Updated by Steffen Ritter almost 11 years ago

  • Status changed from New to Accepted

I know about it - stumbled across it myself...
Problem is: we would need a systematic rewrite of the typolink function...

#2

Updated by Steffen Gebert almost 11 years ago

But that's such an obvious bug that has to be fixed - independent of a rewrite of typolink.

#3

Updated by Steffen Ritter almost 11 years ago

Steffen Gebert wrote:

But that's such an obvious bug that has to be fixed - independent of a rewrite of typolink.

if you see no side effects... I fear about them...
It seems obvious, aber there must have been a reason, to do it like it has been done...

This should be tested in complex multi-domain installations for some time before including it into an release? don't you think so?

Could you give it a try at the FW sites? I would test it within the instances I had the problem myself hoping nothing else would break.

#4

Updated by Dmitry Dulepov almost 11 years ago

The proposed change would not work in all cases. The next lines are:

// If go for an absolute link, add site_path if it's not taken care about by absRefPrefix
if (!$GLOBALS['TSFE']->config['config']['absRefPrefix'] && $targetDomain !== '') {
    $targetDomain = $currentDomain . rtrim(t3lib_div::getIndpEnv('TYPO3_SITE_PATH'), '/');
}

So the target domain will be overwritten by the current domain if absRefPrefix is not set.

#5

Updated by Mr. Hudson almost 11 years ago

  • Status changed from Accepted to Under Review

Patch set 1 of change I1b7f1248f8b62bdaae0adeb114c29f42b146daa4 has been pushed to the review server.
It is available at http://review.typo3.org/6708

#6

Updated by Mr. Hudson almost 11 years ago

Patch set 1 of change I11d21d19731c8d5b9337dfef773cb43484a0b291 has been pushed to the review server.
It is available at http://review.typo3.org/6709

#7

Updated by Mr. Hudson almost 11 years ago

Patch set 1 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

#8

Updated by Mr. Hudson almost 11 years ago

Patch set 2 of change I1b7f1248f8b62bdaae0adeb114c29f42b146daa4 has been pushed to the review server.
It is available at http://review.typo3.org/6708

#9

Updated by Mr. Hudson almost 11 years ago

Patch set 2 of change I11d21d19731c8d5b9337dfef773cb43484a0b291 has been pushed to the review server.
It is available at http://review.typo3.org/6709

#10

Updated by Mr. Hudson almost 11 years ago

Patch set 2 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

#11

Updated by Mr. Hudson almost 11 years ago

Patch set 3 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

#12

Updated by Steffen Ritter over 10 years ago

  • Target version set to 4.7.0-alpha1
#13

Updated by Oliver Hader over 10 years ago

  • Target version changed from 4.7.0-alpha1 to 4.7.0-alpha2
#14

Updated by Gerrit Code Review over 10 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6708

#15

Updated by Gerrit Code Review over 10 years ago

Patch set 3 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/6709

#16

Updated by Gerrit Code Review over 10 years ago

Patch set 4 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/6710

#17

Updated by Dmitry Dulepov over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#18

Updated by Ernesto Baschny over 10 years ago

  • Target version changed from 4.7.0-alpha2 to 4.5.11
#19

Updated by Riccardo De Contardi almost 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF