[BUGFIX] t3lib_BEfunc::getViewDomain() returns wrong or no domain
authorJaume Prat <prat.jaume@gmail.com>
Tue, 22 Nov 2011 09:57:14 +0000 (10:57 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Mon, 12 Mar 2012 16:28:40 +0000 (17:28 +0100)
If the TYPO3 BE host name is not configured as a sys_domain record
t3lib_BEfunc::getViewDomain() will always return TYPO3 BE host name
and not the first domain of the root line of the page which is
being previewed.

Furthermore, if the TYPO3 BE host name is configured as a sys_domain
but the current root line does not contain a valid domain record,
t3lib_BEfunc::getViewDomain() will return only 'http://' ie. no domain.

Change-Id: I12f2fa3aaee785e4577a93a61aad3b136ae03756
Fixes: #30892
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/9317
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
t3lib/class.t3lib_befunc.php

index 67199fe..9cdef30 100644 (file)
@@ -2978,17 +2978,28 @@ final class t3lib_BEfunc {
                        // checks alternate domains
                if (count($rootLine) > 0) {
                        $urlParts = parse_url($domain);
-                       if (self::getDomainStartPage($urlParts['host'], $urlParts['path'])) {
+
                                /** @var t3lib_pageSelect $sysPage */
-                               $sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
+                       $sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
 
-                               $page = (array)$sysPage->getPage($pageId);
-                               $protocol = 'http';
-                               if ($page['url_scheme'] == t3lib_utility_Http::SCHEME_HTTPS || ($page['url_scheme'] == 0 && t3lib_div::getIndpEnv('TYPO3_SSL'))) {
-                                       $protocol = 'https';
-                               }
+                       $page = (array)$sysPage->getPage($pageId);
+                       $protocol = 'http';
+                       if ($page['url_scheme'] == t3lib_utility_Http::SCHEME_HTTPS || ($page['url_scheme'] == 0 && t3lib_div::getIndpEnv('TYPO3_SSL'))) {
+                               $protocol = 'https';
+                       }
+
+                       $domainName = self::firstDomainRecord($rootLine);
 
-                               $domain = $protocol . '://' . self::firstDomainRecord($rootLine);
+                       if ($domainName) {
+                               $domain = $domainName;
+                       } else {
+                               $domainRecord = self::getDomainStartPage($urlParts['host'], $urlParts['path']);
+                               $domain = $domainRecord['domainName'];
+                       }
+                       if ($domain) {
+                               $domain = $protocol . '://' . $domain;
+                       } else {
+                               $domain = rtrim(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), '/');
                        }
                }