Skip to content

Commit

Permalink
[TASK] Reports: Make status compatible to StatusProviderInterface
Browse files Browse the repository at this point in the history
Adjust method signature and implement new method 'getLabel()'.

Use new class ContextualFeedbackSeverity as status code.

Resolves: #3376
  • Loading branch information
3l73 authored and dkd-kaehm committed Oct 28, 2022
1 parent 7331d7d commit f671e75
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 53 deletions.
19 changes: 14 additions & 5 deletions Classes/Report/AccessFilterPluginInstalledStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ApacheSolrForTypo3\Solr\System\Solr\Service\SolrAdminService;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Throwable;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand Down Expand Up @@ -53,12 +54,12 @@ class AccessFilterPluginInstalledStatus extends AbstractSolrStatus
* Solr server. Only adds an entry if the Access Filter Query Parser Plugin
* is not configured.
*
* @return array
*
* @throws DBALDriverException
* @throws Throwable
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];
$solrConnections = GeneralUtility::makeInstance(ConnectionManager::class)->getAllConnections();
Expand All @@ -82,6 +83,14 @@ public function getStatus()
return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/access-filter';
}

/**
* Checks whether the Solr plugin is installed.
*
Expand All @@ -106,7 +115,7 @@ protected function checkPluginInstallationStatus(SolrAdminService $adminService)
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::WARNING
ContextualFeedbackSeverity::WARNING
);
}

Expand Down Expand Up @@ -135,7 +144,7 @@ protected function checkPluginVersion(SolrAdminService $adminService): ?Status
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::WARNING
ContextualFeedbackSeverity::WARNING
);
}

Expand Down
18 changes: 13 additions & 5 deletions Classes/Report/AllowUrlFOpenStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Report;

use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand All @@ -30,19 +31,18 @@ class AllowUrlFOpenStatus extends AbstractSolrStatus
{
/**
* Checks whether allow_url_fopen is enabled.
* @noinspection PhpMissingReturnTypeInspection
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
* @return array
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];
$severity = Status::OK;
$severity = ContextualFeedbackSeverity::OK;
$value = 'On';
$message = '';

if (!ini_get('allow_url_fopen')) {
$severity = Status::ERROR;
$severity = ContextualFeedbackSeverity::ERROR;
$value = 'Off';
$message = 'allow_url_fopen must be enabled in php.ini to allow
communication between TYPO3 and the Apache Solr server.
Expand All @@ -64,4 +64,12 @@ public function getStatus()

return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/allow-url-open';
}
}
17 changes: 13 additions & 4 deletions Classes/Report/FilterVarStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Report;

use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand All @@ -31,13 +32,13 @@ class FilterVarStatus extends AbstractSolrStatus
/**
* Checks whether allow_url_fopen is enabled.
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
* @return array
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];

$validUrl = 'http://www.typo3-solr.com';
$validUrl = 'https://www.typo3-solr.com';
if (!filter_var($validUrl, FILTER_VALIDATE_URL)) {
$message = 'You are using a PHP version that is affected by a bug in
function filter_var(). This bug causes said function to
Expand All @@ -53,10 +54,18 @@ function filter_var(). This bug causes said function to
'PHP filter_var() bug',
'Affected PHP version detected.',
$message,
Status::ERROR
ContextualFeedbackSeverity::ERROR
);
}

return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/filter-var';
}
}
19 changes: 14 additions & 5 deletions Classes/Report/SchemaStatus.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\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand Down Expand Up @@ -50,12 +51,12 @@ class SchemaStatus extends AbstractSolrStatus
* Solr server. Only adds an entry if a schema other than the
* recommended one was found.
*
* @return array
*
* @throws DBALDriverException
* @throws Throwable
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];
/** @var $connectionManager ConnectionManager */
Expand All @@ -77,7 +78,7 @@ public function getStatus()
/** @scrutinizer ignore-type */
$pingFailedMsg,
/** @scrutinizer ignore-type */
Status::ERROR
ContextualFeedbackSeverity::ERROR
);
$reports[] = $status;
continue;
Expand All @@ -96,12 +97,20 @@ public function getStatus()
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::WARNING
ContextualFeedbackSeverity::WARNING
);
$reports[] = $status;
}
}

return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/schema';
}
}
22 changes: 16 additions & 6 deletions Classes/Report/SiteHandlingStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Throwable;
use TYPO3\CMS\Core\Site\Entity\Site as Typo3Site;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand Down Expand Up @@ -54,12 +55,12 @@ class SiteHandlingStatus extends AbstractSolrStatus
*
* @var SiteRepository
*/
protected $siteRepository;
protected SiteRepository $siteRepository;

/**
* @var ExtensionConfiguration
*/
protected $extensionConfiguration;
protected ExtensionConfiguration $extensionConfiguration;

/**
* SolrStatus constructor.
Expand All @@ -75,13 +76,14 @@ public function __construct(
}

/**
* Verifies the site configuration.
*
* @return array
*
* @throws DBALDriverException
* @throws Throwable
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];

Expand All @@ -97,7 +99,7 @@ public function getStatus()
/** @scrutinizer ignore-type */
vsprintf('The configured Site "%s" is not TYPO3 managed site. Please refer to TYPO3 site management docs and configure the site properly.', [$site->getLabel()]),
/** @scrutinizer ignore-type */
Status::ERROR
ContextualFeedbackSeverity::ERROR
);
continue;
}
Expand Down Expand Up @@ -147,10 +149,18 @@ protected function generateValidationReportForSingleSite(Typo3Site $ypo3Site): S
/** @scrutinizer ignore-type */
$renderedReport,
/** @scrutinizer ignore-type */
$globalPassedStateForThisSite == true ? Status::OK : Status::ERROR
$globalPassedStateForThisSite == true ? ContextualFeedbackSeverity::OK : ContextualFeedbackSeverity::ERROR
);
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/site-handling';
}

/**
* Generates the validation result array for using them in standalone view as a table row.
*
Expand Down
15 changes: 12 additions & 3 deletions Classes/Report/SolrConfigStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ApacheSolrForTypo3\Solr\ConnectionManager;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Throwable;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand Down Expand Up @@ -49,12 +50,12 @@ class SolrConfigStatus extends AbstractSolrStatus
* Solr server. Only adds an entry if a solrconfig other than the
* recommended one was found.
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
* @return array
*
* @throws DBALDriverException
* @throws Throwable
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];
$solrConnections = GeneralUtility::makeInstance(ConnectionManager::class)->getAllConnections();
Expand All @@ -74,7 +75,7 @@ public function getStatus()
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::WARNING
ContextualFeedbackSeverity::WARNING
);

$reports[] = $status;
Expand All @@ -83,4 +84,12 @@ public function getStatus()

return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/config';
}
}
21 changes: 14 additions & 7 deletions Classes/Report/SolrConfigurationStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use RuntimeException;
use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Reports\Status;

Expand All @@ -38,12 +39,12 @@ class SolrConfigurationStatus extends AbstractSolrStatus
/**
* @var ExtensionConfiguration
*/
protected $extensionConfiguration;
protected ExtensionConfiguration $extensionConfiguration;

/**
* @var FrontendEnvironment
*/
protected $frontendEnvironment;
protected FrontendEnvironment $frontendEnvironment;

/**
* SolrConfigurationStatus constructor.
Expand All @@ -64,10 +65,8 @@ public function __construct(
* @return array
*
* @throws DBALDriverException
*
* @noinspection PhpMissingReturnTypeInspection see {@link \TYPO3\CMS\Reports\StatusProviderInterface::getStatus()}
*/
public function getStatus()
public function getStatus(): array
{
$reports = [];

Expand All @@ -87,6 +86,14 @@ public function getStatus()
return $reports;
}

/**
* {@inheritDoc}
*/
public function getLabel(): string
{
return 'solr/configuration';
}

/**
* Checks whether the "Use as Root Page" page property has been set for any
* site.
Expand All @@ -110,7 +117,7 @@ protected function getRootPageFlagStatus(): ?Status
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::ERROR
ContextualFeedbackSeverity::ERROR
);
}

Expand Down Expand Up @@ -138,7 +145,7 @@ protected function getConfigIndexEnableStatus(): ?Status
/** @scrutinizer ignore-type */
$report,
/** @scrutinizer ignore-type */
Status::WARNING
ContextualFeedbackSeverity::WARNING
);
}

Expand Down

0 comments on commit f671e75

Please sign in to comment.