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: 9.3.0, 9.4.0, 9.4.1, 9.5.0.

It is always recommended to use the latest tested version.

Resolves: #3955
  • Loading branch information
dkd-friedrich committed Feb 22, 2024
1 parent db79cbd commit b61f1c0
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function handlePageMovement(int $uid, ?int $previousParentId = null): voi
$subPageIds = $this->getSubPageIds($uid);
array_walk(
$subPageIds,
fn(int $subPageId) => $this->collectGarbage('pages', $subPageId)
fn (int $subPageId) => $this->collectGarbage('pages', $subPageId)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/IndexQueue/FrontendHelper/UserGroupDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function getFrontendGroups(): array
$frontendGroups = array_unique($frontendGroups);
$frontendGroups = array_filter(
array_values($frontendGroups),
static fn(int $val): bool => ($val !== -1)
static fn (int $val): bool => ($val !== -1)
);

if (empty($frontendGroups)) {
Expand Down
26 changes: 17 additions & 9 deletions Classes/Report/SolrVersionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ApacheSolrForTypo3\Solr\Domain\Site\Exception\UnexpectedTYPO3SiteInitializationException;
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand All @@ -32,11 +33,6 @@
*/
class SolrVersionStatus extends AbstractSolrStatus
{
/**
* Required Solr version. The version that gets installed when using the provided Docker image.
*/
public const REQUIRED_SOLR_VERSION = '9.3.0';

/**
* Compiles a version check against each configured Solr server.
*
Expand Down Expand Up @@ -65,9 +61,10 @@ public function getStatus(): array
}

$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',
Expand All @@ -79,12 +76,16 @@ public function getStatus(): array
}

$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,
'Apache Solr Version',
'Outdated, Unsupported',
'Unsupported',
$report,
ContextualFeedbackSeverity::ERROR
);
Expand All @@ -95,6 +96,13 @@ public function getStatus(): array
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'] ?? [];
}

/**
* {@inheritDoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion Docker/SolrServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM solr:9.3.0
FROM solr:9.5.0
MAINTAINER dkd Internet Service GmbH <[email protected]>
ENV TERM linux

Expand Down
10 changes: 6 additions & 4 deletions Documentation/Appendix/VersionMatrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ List of EXT:solr versions and the matching versions of Apache Solr and TYPO3 tha
------------------------------- ---------------------------------------------- -------------------------------- --------------- ---------------------------------
TYPO3 EXT:solr EXT:tika EXT:solrfal EXT:solrconsole EXT:solrdebugtools EXT:solrfluidgrouping EXT:solrmlt Apache Solr Configset
========= ========== ========== =========== =============== ================== ================================ =============== =============== =================
12.4 12.0 12.0 12.0 12.0 (Ø) 12.0 N/A (integrated in EXT:solr) 12.0 (Ø) 9.3.0 ext_solr_12_0_0
11.5 11.5 11.0 11.0 11.0 11.0 11.0 11.0 (Ø) 8.11.1 ext_solr_11_5_0
12.4 12.0 12.0 12.0 12.0 12.0 N/A (integrated in EXT:solr) 12.0 (Ø) 9.5.0¹ ext_solr_12_0_0
11.5 11.5 11.0 11.0 11.0 11.0 11.0 11.0 (Ø) 8.11. ext_solr_11_5_0
========= ========== ========== =========== =============== ================== ================================ =============== =============== =================

| Ø - not yet available
| ᾱ - non stable alpha release
| β - non stable beta release
| rc - release candidate available
|¹ - recommended Apache Solr version, check version matrix in composer.json (composer info:solr-versions) for full list
.. important::

Expand All @@ -40,13 +41,14 @@ selected older versions. The following table illustrates the offers and availabl
-------------------------------- ---------------------------------------------- ------------------------------------
TYPO3 EXT:solr EXT:tika EXT:solrfal EXT:solrconsole EXT:solrdebugtools Apache Solr Configset
========= =========== ========== =========== =============== ================== =============== ====================
10.4 11.2.4+ Ø 10.0 10.0 10.0 10.0 9.2.1 ext_solr_11_2_0_elts
9.5-10.4 11.0.8+ 6.0.3+ 8.0.2+ 4.0.2+ 1.1.3+ 9.2.1 ext_solr_11_0_0_elts
10.4 11.2.4+ Ø 10.0 10.0 10.0 10.0 9.5.0¹ ext_solr_11_2_0_elts
9.5-10.4 11.0.8+ 6.0.3+ 8.0.2+ 4.0.2+ 1.1.3+ 9.5.0¹ ext_solr_11_0_0_elts
========= =========== ========== =========== =============== ================== =============== ====================

Our Apache Solr for TYPO3 EB-partners newsletter will keep you updated!

Ø - not yet available
¹ - recommended Apache Solr version, check version matrix in composer.json (composer info:solr-versions) for full list

No longer supported versions
----------------------------
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>
2 changes: 1 addition & 1 deletion Tests/Integration/Report/SolrVersionStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function canGetAGreenSolrConfigStatusAgainstTestServer(): void
self::assertEmpty(
array_filter(
$results,
static fn(Status $status): bool => $status->getSeverity() !== ContextualFeedbackSeverity::OK
static fn (Status $status): bool => $status->getSeverity() !== ContextualFeedbackSeverity::OK
),
'We expect to get no violations against the test Solr server '
);
Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
}
},
"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/vendor/apache-solr-for-typo3",
"[ -L .Build/vendor/apache-solr-for-typo3/solr ] || ln -snvf ../../../. .Build/vendor/apache-solr-for-typo3/solr"
Expand Down Expand Up @@ -143,7 +149,12 @@
"ext-solrconsole": "^12.0",
"ext-solrdebugtools": "^12.0",
"ext-solrmlt": "^12.0",
"Apache-Solr": "9.3.0",
"Apache-Solr": [
"9.5.0",
"9.4.1",
"9.4.0",
"9.3.0"
],
"configset": "ext_solr_12_0_0"
},
"ext-solrfal": {
Expand Down

0 comments on commit b61f1c0

Please sign in to comment.