Skip to content

Commit

Permalink
[TASK] Support several Apache Solr versions
Browse files Browse the repository at this point in the history
As incompatibilities can also occur in minor versions, all versions
will be explicitly tested and listed.

Currently tested and supported versions are: 8.11.1, 8.11.2., 8.11.3

It is always recommended to use the latest tested version.

Note: Apache Solr 8.11.3 contains a breaking change, see security
fix "SOLR-14853: Make enableRemoteStreaming option global; not
configSet". EXT:solr relies on stream bodies which aren't enabled
by default since 8.11.3. EXT:solr 11.5.6 contains all required
settings, but if you're updating and not using our Docker image,
you have to set "enableRemoteStreaming=true" and
"solr.enableStreamBody=true". TYPO3 reports module will
print a warning if you have to reconfigure.

Ports: TYPO3-Solr#3956
Resolves: TYPO3-Solr#3955
  • Loading branch information
dkd-friedrich committed Feb 23, 2024
1 parent cba463b commit b253ee3
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 46 deletions.
44 changes: 24 additions & 20 deletions Classes/Report/SolrVersionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Throwable;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand All @@ -32,14 +33,6 @@
*/
class SolrVersionStatus extends AbstractSolrStatus
{
/**
* Required Solr version. The version that gets installed when using the
* provided install-script EXT:solr/Resources/Private/Install/install-solr.sh
*
* @var string
*/
const REQUIRED_SOLR_VERSION = '8.11.1';

/**
* Compiles a version check against each configured Solr server.
*
Expand All @@ -61,38 +54,42 @@ public function getStatus()
$pingFailedMsg = 'Could not ping solr server, can not check version ' . $url;
$status = GeneralUtility::makeInstance(
Status::class,
/** @scrutinizer ignore-type */
'Apache Solr Version',
/** @scrutinizer ignore-type */
'Not accessible',
/** @scrutinizer ignore-type */
$pingFailedMsg,
/** @scrutinizer ignore-type */
Status::ERROR
);
$reports[] = $status;
continue;
}

$solrVersion = $coreAdmin->getSolrServerVersion();
$isOutdatedVersion = version_compare($this->getCleanSolrVersion($solrVersion), self::REQUIRED_SOLR_VERSION, '<');
$supportedSolrVersions = $this->getSupportedSolrVersions();
$isSupported = in_array($this->getCleanSolrVersion($solrVersion), $supportedSolrVersions);

if (!$isOutdatedVersion) {
if ($isSupported) {
$reports[] = GeneralUtility::makeInstance(
Status::class,
'Apache Solr Version',
'OK',
'Version of ' . $coreAdmin->__toString() . ' is ok: ' . $solrVersion,
Status::OK
);
continue;
}

$formattedVersion = $this->formatSolrVersion($solrVersion);
$variables = ['requiredVersion' => self::REQUIRED_SOLR_VERSION, 'currentVersion' => $formattedVersion, 'solr' => $coreAdmin];
$variables = [
'supportedSolrVersions' => $supportedSolrVersions,
'currentVersion' => $formattedVersion,
'solr' => $coreAdmin,
];
$report = $this->getRenderedReport('SolrVersionStatus.html', $variables);
$status = GeneralUtility::makeInstance(
Status::class,
/** @scrutinizer ignore-type */
'Apache Solr Version',
/** @scrutinizer ignore-type */
'Outdated, Unsupported',
/** @scrutinizer ignore-type */
'Unsupported',
$report,
/** @scrutinizer ignore-type */
Status::ERROR
);

Expand All @@ -102,6 +99,13 @@ public function getStatus()
return $reports;
}

protected function getSupportedSolrVersions(): array
{
$composerContents = file_get_contents(ExtensionManagementUtility::extPath('solr') . 'composer.json');
$composerConfiguration = json_decode($composerContents, true, 25, JSON_OBJECT_AS_ARRAY);
return $composerConfiguration['extra']['TYPO3-Solr']['version-matrix']['Apache-Solr'] ?? [];
}

/**
* Gets the clean Solr version in case of a custom build which may have
* additional information in the version string.
Expand Down
8 changes: 6 additions & 2 deletions Docker/SolrServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
FROM solr:8.11.1
FROM solr:8.11.3
MAINTAINER dkd Internet Service GmbH <[email protected]>
ENV TERM linux

USER root
RUN rm -fR /opt/solr/server/solr/*
RUN rm -fR /opt/solr/server/solr/* \
&& echo '# EXT:solr relevant changes: ' >> /etc/default/solr.in.sh \
&& echo 'SOLR_OPTS="$SOLR_OPTS -Dsolr.enableRemoteStreaming=true -Dsolr.enableStreamBody=true"' >> /etc/default/solr.in.sh \
&& echo '# END: EXT:solr' >> /etc/default/solr.in.sh

USER solr

COPY --chown=solr:solr Resources/Private/Solr/ /var/solr/data
Expand Down
9 changes: 8 additions & 1 deletion Documentation/Appendix/VersionMatrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ Requirements for EXT:solr* 11.5 stack
------------------------------- ---------------------------------------------- --------------------------------------------- ---------------------------------
TYPO3 EXT: solr EXT:tika EXT:solrfal EXT:solrconsole EXT:solrdebugtools EXT:solrfluidgrouping EXT:solrmlt Apache Solr Configset
========= ========== ========== =========== =============== ================== ============================= =============== =============== =================
11.5 11.5 11.0 11.0 11.0 11.0 11.0 11.0 (Ø) 8.11.1 ext_solr_11_5_0
11.5 11.5 11.0 11.0 11.0 11.0 11.0 11.0 (Ø) 8.11. ext_solr_11_5_0
========= ========== ========== =========== =============== ================== ============================= =============== =============== =================

|¹ - recommended Apache Solr version, check version matrix in composer.json (composer info:solr-versions) for full list
.. warning::
Apache Solr 8.11.3 contains a breaking change, see security fix "SOLR-14853: Make enableRemoteStreaming option global; not configSet". EXT:solr relies on stream bodies
which aren't enabled by default since 8.11.3. EXT:solr 11.5.6 contains all required settings, but if you're updating and not using our Docker image, you have to
set "enableRemoteStreaming=true" and "solr.enableStreamBody=true". TYPO3 reports module will print a warning if you have to reconfigure.
9 changes: 9 additions & 0 deletions Documentation/Releases/solr-release-11-5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
Releases 11.5
=============


Release 11.5.6
--------------

.. warning::
Apache Solr 8.11.3 contains a breaking change, see security fix "SOLR-14853: Make enableRemoteStreaming option global; not configSet". EXT:solr relies on stream bodies
which aren't enabled by default since 8.11.3. EXT:solr 11.5.6 contains all required settings, but if you're updating and not using our Docker image, you have to
set "enableRemoteStreaming=true" and "solr.enableStreamBody=true". TYPO3 reports module will print a warning if you have to reconfigure.

Release 11.5.5
--------------

Expand Down
52 changes: 32 additions & 20 deletions Resources/Private/Templates/Backend/Reports/SolrVersionStatus.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
<p style="margin-bottom: 10px;">Found an
outdated Apache Solr server version. <br />The <strong>minimum
required version is <code>{requiredVersion}</code></strong>, you have <code>{currentVersion}</code>.</p>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>

<p style="margin-bottom: 10px;">Found an unsupported Apache Solr server version. <br />
It is strongly recommended to use one of the explicitly tested versions, preferably the latest one.<br />
The currently supported versions are:
<f:for each="{supportedSolrVersions}" as="version" iteration="iterator">
<strong><code>{version}</code></strong>{f:if(condition: '{iterator.isLast}', then: '.', else: ',')}
</f:for>
<br />Your version is: <code>{currentVersion}</code>.
</p>
<table class="table table-condensed table-hover table-striped">
<thead>
<tr>
<td colspan="2">Affected Solr server</td>
</tr>
</thead>
<tr>
<th>Host</th>
<td>{solr.primaryEndpoint.host}</td>
</tr>
<tr>
<th>Path</th>
<td>{solr.corePath}</td>
</tr>
<tr>
<th>Port</th>
<td>{solr.primaryEndpoint.port}</td>
</tr>
<thead>
<tr>
<td colspan="2">Affected Solr server</td>
</tr>
</thead>
<tr>
<th>Host</th>
<td>{solr.primaryEndpoint.host}</td>
</tr>
<tr>
<th>Path</th>
<td>{solr.corePath}</td>
</tr>
<tr>
<th>Port</th>
<td>{solr.primaryEndpoint.port}</td>
</tr>
</table>

</html>
12 changes: 10 additions & 2 deletions Tests/Integration/Report/SolrVersionStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ApacheSolrForTypo3\Solr\Report\SolrVersionStatus;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

/**
* Integration test for the solr version test
Expand All @@ -41,7 +42,14 @@ public function canGetAGreenSolrConfigStatusAgainstTestServer()

/** @var $solrVersionStatus SolrVersionStatus */
$solrVersionStatus = GeneralUtility::makeInstance(SolrVersionStatus::class);
$violations = $solrVersionStatus->getStatus();
self::assertEmpty($violations, 'We expect to get no violations against the test solr server');
$results = $solrVersionStatus->getStatus();
self::assertCount(6, $results);
self::assertEmpty(
array_filter(
$results,
static fn (Status $status): bool => $status->getSeverity() !== Status::OK
),
'We expect to get no violations against the test Solr server '
);
}
}
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
"tests:unit": "Runs unit tests"
},
"scripts": {
"info:solr-versions": [
"@composer config extra.TYPO3-Solr.version-matrix.Apache-Solr"
],
"info:recommended-solr-version": [
"@composer config extra.TYPO3-Solr.version-matrix.Apache-Solr.0"
],
"post-autoload-dump": [
"mkdir -p .Build/Web/typo3conf/ext/",
"[ -L .Build/Web/typo3conf/ext/solr ] || ln -snvf ../../../../. .Build/Web/typo3conf/ext/solr"
Expand Down Expand Up @@ -140,7 +146,11 @@
"ext-solrdebugtools": "^11.0",
"ext-solrfluidgrouping": "^11.0",
"ext-solrmlt": "^11.0",
"Apache-Solr": "8.11.1",
"Apache-Solr": [
"8.11.3",
"8.11.2",
"8.11.1"
],
"configset": "ext_solr_11_5_0"
},
"ext-solrfal": {
Expand Down

0 comments on commit b253ee3

Please sign in to comment.