Skip to content

Commit

Permalink
[BUGFIX:BP:11] set base uri to face frontend request
Browse files Browse the repository at this point in the history
Fixes: TYPO3-Solr#2914
closes: TYPO3-Solr#2915
Backported from: TYPO3-Solr#2982
  • Loading branch information
Achim Fritz authored and dkd-kaehm committed Aug 17, 2021
1 parent b7a39c1 commit 2c34ae9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Classes/FrontendEnvironment/Tsfe.php
Expand Up @@ -78,7 +78,8 @@ public function initializeTsfe($pageId, $language = 0)
$this->requestCache[$cacheId] = $request
->withAttribute('site', $site)
->withAttribute('language', $siteLanguage)
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE);
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE)
->withUri($site->getBase());
}
$GLOBALS['TYPO3_REQUEST'] = $this->requestCache[$cacheId];

Expand Down
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<sys_template>
<uid>1</uid>
<pid>1</pid>
<root>1</root>
<clear>3</clear>
<config>
<![CDATA[
page = PAGE
page.typeNum = 0
page.bodyTag = <body>
config.index_enable = 1
plugin.tx_solr {
enabled = 1
}
]]>
</config>
<sorting>100</sorting>
</sys_template>
<pages>
<uid>1</uid>
<is_siteroot>1</is_siteroot>
<doktype>1</doktype>
<title>disabled for default language</title>
<l18n_cfg>1</l18n_cfg>
</pages>
<pages>
<uid>404</uid>
<pid>1</pid>
<title>error page, required for testing</title>
</pages>
</dataset>
54 changes: 54 additions & 0 deletions Tests/Integration/FrontendEnvironment/TsfeTest.php
@@ -0,0 +1,54 @@
<?php
namespace ApacheSolrForTypo3\Solr\Tests\Integration\FrontendEnvironment;


use ApacheSolrForTypo3\Solr\FrontendEnvironment\Tsfe;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class TsfeTest extends IntegrationTest
{

/**
* @test
* @expectedException \RuntimeException
*/
public function initializeTsfeWithNoDefaultPageAndPageErrorHandlerDoNotThrowAnError()
{
$this->importDataSetFromFixture('initialize_tsfe_with_no_default_page_and_page_error_handler_do_not_throw_an_error.xml');

$defaultLanguage = $this->buildDefaultLanguageConfiguration('EN', '/en/');
$defaultLanguage['solr_core_read'] = 'core_en';

$this->writeSiteConfiguration(
'integration_tree_one',
$this->buildSiteConfiguration(1, 'http://testone.site/'),
[
$defaultLanguage,
],
$this->buildErrorHandlingConfiguration('Page', [404])
);

$scheme = 'http';
$host = 'localhost';
$port = 8999;
$globalSolrSettings = [
'solr_scheme_read' => $scheme,
'solr_host_read' => $host,
'solr_port_read' => $port,
'solr_timeout_read' => 20,
'solr_path_read' => '/solr/',
'solr_use_write_connection' => false,
];
$this->mergeSiteConfiguration('integration_tree_one', $globalSolrSettings);
clearstatcache();
usleep(500);
$siteCreatedHash = md5($scheme . $host . $port . '0-PageErrorHandler');
self::$lastSiteCreated = $siteCreatedHash;

$tsfe = GeneralUtility::makeInstance(Tsfe::class);
$tsfe->initializeTsfe(1);

}

}

0 comments on commit 2c34ae9

Please sign in to comment.