1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApacheSolrForTypo3\Solr\Report; |
19
|
|
|
|
20
|
|
|
use ApacheSolrForTypo3\Solr\ConnectionManager; |
21
|
|
|
use Doctrine\DBAL\Driver\Exception as DBALDriverException; |
22
|
|
|
use Throwable; |
23
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
24
|
|
|
use TYPO3\CMS\Reports\Status; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Provides a status report about which solrconfig version is used and checks |
28
|
|
|
* whether it fits the recommended version shipping with the extension. |
29
|
|
|
* |
30
|
|
|
* @author Ingo Renner <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class SolrConfigStatus extends AbstractSolrStatus |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* The config name property is constructed as follows: |
36
|
|
|
* |
37
|
|
|
* tx_solr - The extension key |
38
|
|
|
* x-y-z - The extension version this config is meant to work with |
39
|
|
|
* YYYYMMDD - The date the config file was changed the last time |
40
|
|
|
* |
41
|
|
|
* Must be updated when changing the solrconfig. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
const RECOMMENDED_SOLRCONFIG_VERSION = 'tx_solr-11-5-0--20211001'; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Compiles a collection of solrconfig version checks against each configured |
49
|
|
|
* Solr server. Only adds an entry if a solrconfig other than the |
50
|
|
|
* recommended one was found. |
51
|
|
|
* |
52
|
|
|
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()} |
53
|
|
|
* |
54
|
|
|
* @throws DBALDriverException |
55
|
|
|
* @throws Throwable |
56
|
|
|
*/ |
57
|
1 |
|
public function getStatus() |
58
|
|
|
{ |
59
|
1 |
|
$reports = []; |
60
|
1 |
|
$solrConnections = GeneralUtility::makeInstance(ConnectionManager::class)->getAllConnections(); |
61
|
|
|
|
62
|
1 |
|
foreach ($solrConnections as $solrConnection) { |
63
|
1 |
|
$adminService = $solrConnection->getAdminService(); |
64
|
|
|
|
65
|
1 |
|
if ($adminService->ping() && $adminService->getSolrconfigName() != self::RECOMMENDED_SOLRCONFIG_VERSION) { |
66
|
|
|
$variables = ['solr' => $adminService, 'recommendedVersion' => self::RECOMMENDED_SOLRCONFIG_VERSION]; |
67
|
|
|
$report = $this->getRenderedReport('SolrConfigStatus.html', $variables); |
68
|
|
|
$status = GeneralUtility::makeInstance( |
69
|
|
|
Status::class, |
70
|
|
|
/** @scrutinizer ignore-type */ |
71
|
|
|
'Solrconfig Version', |
72
|
|
|
/** @scrutinizer ignore-type */ |
73
|
|
|
'Unsupported solrconfig.xml', |
74
|
|
|
/** @scrutinizer ignore-type */ |
75
|
|
|
$report, |
76
|
|
|
/** @scrutinizer ignore-type */ |
77
|
|
|
Status::WARNING |
78
|
|
|
); |
79
|
|
|
|
80
|
|
|
$reports[] = $status; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
return $reports; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|