[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)
committerSusanne Moog <typo3@susannemoog.de>
Sat, 28 Jan 2012 14:29:28 +0000 (15:29 +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: I8118d2c932b2a9d6c3d2dae51c5707a6371784d8
Fixes: #30892
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6830
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Dmitry Dulepov
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
t3lib/class.t3lib_befunc.php

index 83416a3..2cfe525 100644 (file)
@@ -2615,18 +2615,22 @@ 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');
 
-                               $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';
-                               }
+                               /** @var t3lib_pageSelect $sysPage */
+                       $sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
 
-                               $domain = $protocol . '://' . self::firstDomainRecord($rootLine);
+                       $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';
+                       }
+                       $domainRecord = self::getDomainStartPage($urlParts['host'], $urlParts['path']);
+                       if ($domainRecord && isset($domainRecord['domainName'])) {
+                               $domain = $domainRecord['domainName'];
+                       } else {
+                               $domain = self::firstDomainRecord($rootLine);
                        }
+                       $domain = $protocol . '://' . $domain;
                }
 
                return $domain;