From e09615eaba80eb1ae16f6f7d8701e4ebfe7e6478 Mon Sep 17 00:00:00 2001 From: Markus Friedrich Date: Fri, 17 May 2024 14:16:40 +0200 Subject: [PATCH] [TASK] Remove content stream usage Drops the usage of content streams for Solr queries, this removes the dependency to SOLR_ENABLE_STREAM_BODY. Resolves: #3750 --- Classes/Report/SolrStatus.php | 21 +------------------ .../System/Solr/Service/SolrAdminService.php | 21 ------------------- Docker/SolrServer/Dockerfile | 6 +----- .../Solr/ConfigurationStructures.rst | 1 - .../Templates/Backend/Reports/SolrStatus.html | 6 ------ Tests/Integration/IntegrationTestBase.php | 13 +++++++++++- 6 files changed, 14 insertions(+), 54 deletions(-) diff --git a/Classes/Report/SolrStatus.php b/Classes/Report/SolrStatus.php index d525de1b24..8b35de06b5 100644 --- a/Classes/Report/SolrStatus.php +++ b/Classes/Report/SolrStatus.php @@ -119,11 +119,10 @@ protected function getConnectionStatus(Site $site, array $solrConnection): Statu $pingTime = $this->checkPingTime($solrAdmin); $configName = $this->checkSolrConfigName($solrAdmin); $schemaName = $this->checkSolrSchemaName($solrAdmin); - $streamBodySetting = $this->checkStreamBodySetting($solrAdmin); /** @phpstan-ignore-next-line */ if ($this->responseStatus !== ContextualFeedbackSeverity::OK) { - $header = 'Failed contacting the Solr server or invalid settings found.'; + $header = 'Failed contacting the Solr server.'; } $variables = [ @@ -136,7 +135,6 @@ protected function getConnectionStatus(Site $site, array $solrConnection): Statu 'configName' => $configName, 'schemaName' => $schemaName, 'accessFilter' => $accessFilter, - 'streamBodySetting' => $streamBodySetting, ]; $report = $this->getRenderedReport('SolrStatus.html', $variables); @@ -227,23 +225,6 @@ protected function checkSolrSchemaName(SolrAdminService $solrAdminService): stri return $solrSchemaMessage; } - protected function checkStreamBodySetting(SolrAdminService $solrAdminService): string - { - $systemProperties = $solrAdminService->getSystemProperties(); - if ($systemProperties === null) { - $this->responseStatus = ContextualFeedbackSeverity::ERROR; - return 'Error determining system properties'; - } - - $streamSetting = (bool)($systemProperties['solr.enableStreamBody'] ?? false); - if (!$streamSetting) { - $this->responseStatus = ContextualFeedbackSeverity::ERROR; - return 'Content Streams not enabled'; - } - - return 'true'; - } - /** * Formats the Apache Solr server version number. By default, this is going * to be the simple major.minor.patch-level version. Custom Builds provide diff --git a/Classes/System/Solr/Service/SolrAdminService.php b/Classes/System/Solr/Service/SolrAdminService.php index fea67f5b8e..f0d47c72ff 100644 --- a/Classes/System/Solr/Service/SolrAdminService.php +++ b/Classes/System/Solr/Service/SolrAdminService.php @@ -40,7 +40,6 @@ class SolrAdminService extends AbstractSolrService public const LUKE_SERVLET = 'admin/luke'; public const SYSTEM_SERVLET = 'admin/system'; public const CORES_SERVLET = '../admin/cores'; - public const PROPERTY_SERVLET = '../admin/info/properties'; public const FILE_SERVLET = 'admin/file'; public const SCHEMA_SERVLET = 'schema'; public const SYNONYMS_SERVLET = 'schema/analysis/synonyms/'; @@ -89,26 +88,6 @@ public function system(): ResponseAdapter return $this->_sendRawGet($this->_constructUrl(self::SYSTEM_SERVLET, ['wt' => 'json'])); } - /** - * Gets system properties - * - * @return array|null - */ - public function getSystemProperties(): ?array - { - $url = $this->_constructUrl(self::PROPERTY_SERVLET, ['wt' => 'json']); - $propertyInformation = $this->_sendRawGet($url); - - $parsedPropertyInformation = $propertyInformation->getParsedData(); - if ($parsedPropertyInformation === null - || !property_exists($parsedPropertyInformation, 'system.properties') - ) { - return null; - } - - return (array)$parsedPropertyInformation->{'system.properties'}; - } - /** * Gets information about the plugins installed in Solr * diff --git a/Docker/SolrServer/Dockerfile b/Docker/SolrServer/Dockerfile index fcf0562f78..0d852b0dbf 100644 --- a/Docker/SolrServer/Dockerfile +++ b/Docker/SolrServer/Dockerfile @@ -11,11 +11,7 @@ RUN rm -fR /opt/solr/server/solr/* \ && groupmod --non-unique --gid "${SOLR_UNIX_GID}" solr \ && chown -R solr:solr /var/solr /opt/solr \ && apt update && apt upgrade -y && apt install sudo -y \ - && echo "solr ALL=NOPASSWD: /docker-entrypoint-initdb.d/as-sudo/*" > /etc/sudoers.d/solr \ - && echo "# EXT:solr relevant changes: " >> /etc/default/solr.in.sh \ - && echo "SOLR_ENABLE_REMOTE_STREAMING=true" >> /etc/default/solr.in.sh \ - && echo "SOLR_ENABLE_STREAM_BODY=true" >> /etc/default/solr.in.sh \ - && echo "# END: EXT:solr" >> /etc/default/solr.in.sh + && echo "solr ALL=NOPASSWD: /docker-entrypoint-initdb.d/as-sudo/*" > /etc/sudoers.d/solr COPY Docker/SolrServer/docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d USER solr diff --git a/Documentation/Solr/ConfigurationStructures.rst b/Documentation/Solr/ConfigurationStructures.rst index c6f509f177..16859ff67e 100644 --- a/Documentation/Solr/ConfigurationStructures.rst +++ b/Documentation/Solr/ConfigurationStructures.rst @@ -65,7 +65,6 @@ When you want to install Solr on your system in another way the following steps * Install the Solr server * Copy the configsets into the configset folder (by default $SOLR_HOME/server/solr/configsets) * Make sure that the solr.xml file ($SOLR_HOME/server/solr/solr.xml) is in place and fits to your Solr version -* Enable Content Streams. EXT:solr uses content streams and requires environment variables SOLR_ENABLE_REMOTE_STREAMING and SOLR_ENABLE_STREAM_BODY to be set, see section `Content Streams in the Reference Guide `__ * Create an init script that starts Solr on boottime. * Secure your Solr port from outside. diff --git a/Resources/Private/Templates/Backend/Reports/SolrStatus.html b/Resources/Private/Templates/Backend/Reports/SolrStatus.html index c6f63d8120..8e111c7514 100644 --- a/Resources/Private/Templates/Backend/Reports/SolrStatus.html +++ b/Resources/Private/Templates/Backend/Reports/SolrStatus.html @@ -48,12 +48,6 @@ Access Filter Plugin {accessFilter} - - Content Streams
(SOLR_ENABLE_REMOTE_STREAMING) - - {streamBodySetting} - - \ No newline at end of file diff --git a/Tests/Integration/IntegrationTestBase.php b/Tests/Integration/IntegrationTestBase.php index 3db3bfd9c1..2e37772cc5 100644 --- a/Tests/Integration/IntegrationTestBase.php +++ b/Tests/Integration/IntegrationTestBase.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Exception\SiteNotFoundException; +use TYPO3\CMS\Core\Http\RequestFactory; use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait; @@ -100,7 +101,17 @@ protected function cleanUpSolrServerAndAssertEmpty(?string $coreName = 'core_en' $this->validateTestCoreName($coreName); // cleanup the solr server - $result = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/' . $coreName . '/update?stream.body=*:*&commit=true'); + $requestFactory = GeneralUtility::makeInstance(RequestFactory::class); + $response = $requestFactory->request( + $this->getSolrConnectionUriAuthority() . '/solr/' . $coreName . '/update', + 'POST', + [ + 'headers' => ['Content-Type' => 'application/xml'], + 'body' => '*:*', + ] + ); + $result = $response->getBody()->getContents(); + if (!str_contains($result, '')) { self::fail('Could not empty solr test index'); }