Bug #24389 » typolink_test.diff
typo3_src/typo3/sysext/cms/tslib/class.tslib_content.php 2011-01-13 15:36:57.000000000 +0100 | ||
---|---|---|
foreach ($targetPageRootline as $data) {
|
||
$targetPageRootlinePids[] = intval($data['uid']);
|
||
}
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'pid, domainName, forced',
|
||
'sys_domain',
|
||
'pid IN (' . implode(',', $targetPageRootlinePids) . ') ' .
|
||
' AND redirectTo=\'\' ' . $this->enableFields('sys_domain'),
|
||
'',
|
||
'sorting ASC'
|
||
);
|
||
// TODO maybe it makes sense to hold all sys_domain records in a cache to save additional DB querys on each typolink
|
||
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$foundDomains[] = preg_replace('/\/$/', '', $row['domainName']);
|
||
if (!isset($firstFoundDomains[$row['pid']])) {
|
||
$firstFoundDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
|
||
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['useCachingFramework']) {
|
||
try {
|
||
$cache = $GLOBALS['typo3CacheManager']->getCache('cacheTypolinkCheckRootline');
|
||
} catch (t3lib_cache_exception_NoSuchCache $e) {
|
||
$cache = $GLOBALS['typo3CacheFactory']->create(
|
||
'cacheTypolinkCheckRootline',
|
||
't3lib_cache_frontend_VariableFrontend',
|
||
't3lib_cache_backend_TransientMemoryBackend'
|
||
);
|
||
}
|
||
}
|
||
|
||
if (is_object($cache) && $cache->has('domainRecords')) {
|
||
$domainRecords = $cache->get('domainRecords');
|
||
}
|
||
|
||
if (! isset($domainRecords)) {
|
||
$domainRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'pid, domainName, forced',
|
||
'sys_domain',
|
||
/*'pid IN (' . implode(',', $targetPageRootlinePids) . ') ' .*/
|
||
' redirectTo=\'\' ' . $this->enableFields('sys_domain'),
|
||
'',
|
||
'sorting ASC'
|
||
);
|
||
if (is_object($cache)) {
|
||
$cache->set('domainRecords', $domainRecords);
|
||
}
|
||
if ($row['forced'] && !isset($firstFoundForcedDomains[$row['pid']])) {
|
||
$firstFoundForcedDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
|
||
}
|
||
|
||
foreach($domainRecords as $domainRecord) {
|
||
if (in_array($domainRecord['pid'], $targetPageRootline)) {
|
||
$foundDomains[] = preg_replace('/\/$/', '', $domainRecord['domainName']);
|
||
if (!isset($firstFoundDomains[$domainRecord['pid']])) {
|
||
$firstFoundDomains[$domainRecord['pid']] = preg_replace('/\/$/', '', $domainRecord['domainName']);
|
||
}
|
||
if ($domainRecord['forced'] && !isset($firstFoundForcedDomains[$domainRecord['pid']])) {
|
||
$firstFoundForcedDomains[$domainRecord['pid']] = preg_replace('/\/$/', '', $domainRecord['domainName']);
|
||
}
|
||
}
|
||
}
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
// Set targetDomain to first found domain record if the target page cannot be reached within the current domain
|
||
if (count($foundDomains) > 0
|