From f86703625f772f777966e20ce08b4e91a53d51a3 Mon Sep 17 00:00:00 2001 From: Markus Friedrich Date: Thu, 8 Sep 2022 09:48:08 +0200 Subject: [PATCH] !!![TASK] Introduce specific EXT:solr exceptions Existing exceptions are now based on the recently introduced generic EXT:solr exception. Additionally based on the new generic EXT:solr exception a further exception is introduced, allowing more targeted handling of exceptions: InvalidIndexQueueInitizalizationPostProcessorException This is a breaking change as the base excepion changed and the new exception is no longer based on \UnexpectedValueException. Resolves: #3763 --- .../Access/RootlineElementFormatException.php | 2 +- Classes/ConnectionManager.php | 2 +- Classes/ContentObject/Classification.php | 2 +- .../Search/AbstractModuleController.php | 2 +- .../Queue/GarbageRemover/AbstractStrategy.php | 2 +- .../Queue/QueueInitializationService.php | 3 ++- .../AbstractBaseEventListener.php | 2 +- .../LastSearches/LastSearchesRepository.php | 3 +-- .../Query/ParameterBuilder/Operator.php | 2 +- .../Facets/InvalidFacetPackageException.php | 2 +- .../Facets/InvalidFacetParserException.php | 2 +- .../Facets/InvalidQueryBuilderException.php | 2 +- .../Facets/InvalidUrlDecoderException.php | 2 +- .../NumericRange/NumericRangeUrlDecoder.php | 2 +- .../ResultSet/Facets/RequirementsService.php | 2 +- .../Result/Parser/ResultParserRegistry.php | 2 +- .../ResultSet/Result/SearchResultBuilder.php | 2 +- .../Search/ResultSet/Sorting/Sorting.php | 2 +- .../ResultSet/Sorting/SortingHelper.php | 2 +- .../InvalidSiteRootPageException.php | 24 +++++++++++++++++ Classes/Domain/Site/SiteRepository.php | 2 +- Classes/Domain/Variants/IdBuilder.php | 2 +- .../Exception/InvalidArgumentException.php | 27 +++++++++++++++++++ .../Exception/IllegalStateException.php | 2 +- .../Exception/IndexingException.php | 2 +- Classes/IndexQueue/Item.php | 2 +- Classes/IndexQueue/NoPidException.php | 2 +- Classes/NoSolrConnectionFoundException.php | 2 -- Classes/PingFailedException.php | 2 -- .../Configuration/TypoScriptConfiguration.php | 2 +- .../WebRootAllReadyDefinedException.php | 2 +- .../System/Object/AbstractClassRegistry.php | 2 +- Classes/System/Records/AbstractRepository.php | 2 +- .../System/Records/Pages/PagesRepository.php | 2 +- Classes/System/Solr/Parser/StopWordParser.php | 2 +- .../System/Solr/Service/SolrAdminService.php | 2 +- Classes/Task/AbstractSolrTask.php | 2 +- Classes/Task/EventQueueWorkerTask.php | 2 +- Classes/Utility/ManagedResourcesUtility.php | 2 +- .../IfHasAccessToModuleViewHelper.php | 2 +- .../ViewHelpers/Uri/AbstractUriViewHelper.php | 2 +- .../Uri/Facet/AbstractValueViewHelper.php | 2 +- .../Domain/Site/SiteRepositoryTest.php | 2 +- Tests/Integration/Domain/Site/SiteTest.php | 2 +- Tests/Integration/IntegrationTest.php | 2 +- .../Helper/RootPageResolverTest.php | 1 + .../ResultSet/Facets/FacetRegistryTest.php | 2 +- .../NumericRangeUrlDecoderTest.php | 2 +- .../Facets/RequirementsServiceTest.php | 7 ++--- .../ResultSet/Sorting/SortingHelperTest.php | 3 ++- .../Search/ResultSet/Sorting/SortingTest.php | 3 ++- 51 files changed, 104 insertions(+), 53 deletions(-) create mode 100644 Classes/Domain/Site/Exception/InvalidSiteRootPageException.php create mode 100644 Classes/Exception/InvalidArgumentException.php diff --git a/Classes/Access/RootlineElementFormatException.php b/Classes/Access/RootlineElementFormatException.php index ade937a738..3a0ce0e23b 100644 --- a/Classes/Access/RootlineElementFormatException.php +++ b/Classes/Access/RootlineElementFormatException.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Access; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; /** * Signals a wrong format for the access definition of a page or the content. diff --git a/Classes/ConnectionManager.php b/Classes/ConnectionManager.php index ad0863e89e..d9e8d2ad99 100644 --- a/Classes/ConnectionManager.php +++ b/Classes/ConnectionManager.php @@ -20,12 +20,12 @@ use ApacheSolrForTypo3\Solr\Domain\Site\Exception\UnexpectedTYPO3SiteInitializationException; use ApacheSolrForTypo3\Solr\Domain\Site\Site; use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository as PagesRepositoryAtExtSolr; use ApacheSolrForTypo3\Solr\System\Solr\Node; use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection; use ApacheSolrForTypo3\Solr\System\Util\SiteUtility; use Doctrine\DBAL\Exception as DBALException; -use InvalidArgumentException; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Site\Entity\Site as Typo3Site; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/ContentObject/Classification.php b/Classes/ContentObject/Classification.php index 786cdae186..2ca88f2c61 100644 --- a/Classes/ContentObject/Classification.php +++ b/Classes/ContentObject/Classification.php @@ -17,7 +17,7 @@ use ApacheSolrForTypo3\Solr\Domain\Index\Classification\Classification as ClassificationItem; use ApacheSolrForTypo3\Solr\Domain\Index\Classification\ClassificationService; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject; diff --git a/Classes/Controller/Backend/Search/AbstractModuleController.php b/Classes/Controller/Backend/Search/AbstractModuleController.php index b9469026c2..30a0b4091e 100644 --- a/Classes/Controller/Backend/Search/AbstractModuleController.php +++ b/Classes/Controller/Backend/Search/AbstractModuleController.php @@ -19,11 +19,11 @@ use ApacheSolrForTypo3\Solr\Domain\Site\Exception\UnexpectedTYPO3SiteInitializationException; use ApacheSolrForTypo3\Solr\Domain\Site\Site; use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface; use ApacheSolrForTypo3\Solr\System\Mvc\Backend\Service\ModuleDataStorageService; use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection as SolrCoreConnection; use Doctrine\DBAL\Exception as DBALException; -use InvalidArgumentException; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Backend\Template\Components\Menu\Menu; use TYPO3\CMS\Backend\Template\ModuleTemplate; diff --git a/Classes/Domain/Index/Queue/GarbageRemover/AbstractStrategy.php b/Classes/Domain/Index/Queue/GarbageRemover/AbstractStrategy.php index 11cff9f6c3..ca851ddc65 100644 --- a/Classes/Domain/Index/Queue/GarbageRemover/AbstractStrategy.php +++ b/Classes/Domain/Index/Queue/GarbageRemover/AbstractStrategy.php @@ -17,12 +17,12 @@ use ApacheSolrForTypo3\Solr\ConnectionManager; use ApacheSolrForTypo3\Solr\Domain\Site\Exception\UnexpectedTYPO3SiteInitializationException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\GarbageCollectorPostProcessor; use ApacheSolrForTypo3\Solr\IndexQueue\Queue; use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface; use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; use Doctrine\DBAL\Exception as DBALException; -use InvalidArgumentException; use TYPO3\CMS\Core\Utility\GeneralUtility; use UnexpectedValueException; diff --git a/Classes/Domain/Index/Queue/QueueInitializationService.php b/Classes/Domain/Index/Queue/QueueInitializationService.php index 7c2124265c..d9a3c7b620 100644 --- a/Classes/Domain/Index/Queue/QueueInitializationService.php +++ b/Classes/Domain/Index/Queue/QueueInitializationService.php @@ -20,6 +20,7 @@ use ApacheSolrForTypo3\Solr\Domain\Site\Site; use ApacheSolrForTypo3\Solr\Event\IndexQueue\AfterIndexQueueHasBeenInitializedEvent; use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\AbstractInitializer; +use ApacheSolrForTypo3\Solr\IndexQueue\QueueInitializationServiceAwareInterface; use ApacheSolrForTypo3\Solr\IndexQueue\QueueInterface; use Doctrine\DBAL\ConnectionException; use Doctrine\DBAL\Exception as DBALException; @@ -42,7 +43,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher = null) { $this->eventDispatcher = $eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class); } - + public function setClearQueueOnInitialization(bool $clearQueueOnInitialization): void { $this->clearQueueOnInitialization = $clearQueueOnInitialization; diff --git a/Classes/Domain/Index/Queue/UpdateHandler/EventListener/AbstractBaseEventListener.php b/Classes/Domain/Index/Queue/UpdateHandler/EventListener/AbstractBaseEventListener.php index 444d96db74..77ab817c1a 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/EventListener/AbstractBaseEventListener.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/EventListener/AbstractBaseEventListener.php @@ -21,8 +21,8 @@ use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\EventListener\Events\ProcessingFinishedEventInterface; use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\Events\DataUpdateEventInterface; use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\GarbageHandler; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration; -use InvalidArgumentException; use Psr\EventDispatcher\EventDispatcherInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Domain/Search/LastSearches/LastSearchesRepository.php b/Classes/Domain/Search/LastSearches/LastSearchesRepository.php index 933ad6e01b..8ced9dc260 100644 --- a/Classes/Domain/Search/LastSearches/LastSearchesRepository.php +++ b/Classes/Domain/Search/LastSearches/LastSearchesRepository.php @@ -15,10 +15,9 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\LastSearches; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository; use Doctrine\DBAL\Exception as DBALException; -use InvalidArgumentException; - use function json_encode; class LastSearchesRepository extends AbstractRepository diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Operator.php b/Classes/Domain/Search/Query/ParameterBuilder/Operator.php index 32f2c2831a..80b8a7aa17 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Operator.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Operator.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; /** * The Operator ParameterProvider is responsible to build the solr query parameters diff --git a/Classes/Domain/Search/ResultSet/Facets/InvalidFacetPackageException.php b/Classes/Domain/Search/ResultSet/Facets/InvalidFacetPackageException.php index aabca67d9b..fa5269346e 100644 --- a/Classes/Domain/Search/ResultSet/Facets/InvalidFacetPackageException.php +++ b/Classes/Domain/Search/ResultSet/Facets/InvalidFacetPackageException.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; -use Exception; +use ApacheSolrForTypo3\Solr\Exception; class InvalidFacetPackageException extends Exception { diff --git a/Classes/Domain/Search/ResultSet/Facets/InvalidFacetParserException.php b/Classes/Domain/Search/ResultSet/Facets/InvalidFacetParserException.php index d333b3f55c..623eff19bc 100644 --- a/Classes/Domain/Search/ResultSet/Facets/InvalidFacetParserException.php +++ b/Classes/Domain/Search/ResultSet/Facets/InvalidFacetParserException.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; -use Exception; +use ApacheSolrForTypo3\Solr\Exception; class InvalidFacetParserException extends Exception { diff --git a/Classes/Domain/Search/ResultSet/Facets/InvalidQueryBuilderException.php b/Classes/Domain/Search/ResultSet/Facets/InvalidQueryBuilderException.php index 120efd09a8..242c37263b 100644 --- a/Classes/Domain/Search/ResultSet/Facets/InvalidQueryBuilderException.php +++ b/Classes/Domain/Search/ResultSet/Facets/InvalidQueryBuilderException.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; -use Exception; +use ApacheSolrForTypo3\Solr\Exception; class InvalidQueryBuilderException extends Exception { diff --git a/Classes/Domain/Search/ResultSet/Facets/InvalidUrlDecoderException.php b/Classes/Domain/Search/ResultSet/Facets/InvalidUrlDecoderException.php index 58d27d7a00..0c8992f20a 100644 --- a/Classes/Domain/Search/ResultSet/Facets/InvalidUrlDecoderException.php +++ b/Classes/Domain/Search/ResultSet/Facets/InvalidUrlDecoderException.php @@ -17,7 +17,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; -use Exception; +use ApacheSolrForTypo3\Solr\Exception; class InvalidUrlDecoderException extends Exception { diff --git a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php index 4ba5fbc2ad..7da2bfbe94 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php +++ b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php @@ -18,7 +18,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetUrlDecoderInterface; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; /** * Parser to build Solr range queries from tx_solr[filter] diff --git a/Classes/Domain/Search/ResultSet/Facets/RequirementsService.php b/Classes/Domain/Search/ResultSet/Facets/RequirementsService.php index f23ba29012..7df500bfaf 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RequirementsService.php +++ b/Classes/Domain/Search/ResultSet/Facets/RequirementsService.php @@ -15,7 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use TYPO3\CMS\Core\Utility\GeneralUtility; /** diff --git a/Classes/Domain/Search/ResultSet/Result/Parser/ResultParserRegistry.php b/Classes/Domain/Search/ResultSet/Result/Parser/ResultParserRegistry.php index 2c6211678f..39b18608a2 100644 --- a/Classes/Domain/Search/ResultSet/Result/Parser/ResultParserRegistry.php +++ b/Classes/Domain/Search/ResultSet/Result/Parser/ResultParserRegistry.php @@ -18,7 +18,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\Parser; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Domain/Search/ResultSet/Result/SearchResultBuilder.php b/Classes/Domain/Search/ResultSet/Result/SearchResultBuilder.php index 2fc37b334f..dbd167ff43 100644 --- a/Classes/Domain/Search/ResultSet/Result/SearchResultBuilder.php +++ b/Classes/Domain/Search/ResultSet/Result/SearchResultBuilder.php @@ -17,8 +17,8 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; -use InvalidArgumentException; use TYPO3\CMS\Core\Utility\GeneralUtility; /** diff --git a/Classes/Domain/Search/ResultSet/Sorting/Sorting.php b/Classes/Domain/Search/ResultSet/Sorting/Sorting.php index 5cf9ca2a8e..c48d074583 100644 --- a/Classes/Domain/Search/ResultSet/Sorting/Sorting.php +++ b/Classes/Domain/Search/ResultSet/Sorting/Sorting.php @@ -18,7 +18,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; /** * Class Sorting diff --git a/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php b/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php index 4ac0bb48b9..92f9086e6e 100644 --- a/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php +++ b/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php @@ -17,7 +17,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting; -use InvalidArgumentException; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use TYPO3\CMS\Core\Utility\GeneralUtility; /** diff --git a/Classes/Domain/Site/Exception/InvalidSiteRootPageException.php b/Classes/Domain/Site/Exception/InvalidSiteRootPageException.php new file mode 100644 index 0000000000..143cd468b3 --- /dev/null +++ b/Classes/Domain/Site/Exception/InvalidSiteRootPageException.php @@ -0,0 +1,24 @@ +expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Requirement for unexisting facet configured'); $resultSet = new SearchResultSet(); diff --git a/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingHelperTest.php b/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingHelperTest.php index 3820e42515..f4700a2891 100644 --- a/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingHelperTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingHelperTest.php @@ -16,6 +16,7 @@ namespace ApacheSolrForTypo3\Solr\Tests\Unit\Domain\Search\ResultSet\Sorting; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\SortingHelper; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\Tests\Unit\SetUpUnitTestCase; /** @@ -49,7 +50,7 @@ public function canGetSortFieldFromUrlParameter() */ public function canThrowExceptionForUnconfiguredSorting() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('No sorting configuration found for option name unconfigured'); $sorting = new SortingHelper([]); $sorting->getSortFieldFromUrlParameter('unconfigured asc'); diff --git a/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingTest.php b/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingTest.php index a2dcd72485..44e3ccc594 100644 --- a/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/Sorting/SortingTest.php @@ -17,6 +17,7 @@ use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\Sorting; +use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException; use ApacheSolrForTypo3\Solr\Tests\Unit\SetUpUnitTestCase; /** @@ -55,7 +56,7 @@ protected function setUp(): void */ public function canNotCreateWhenInvalidDirectionIsPassed() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); new Sorting($this->resultSetMock, 'Color', 'color_s', 'invalid direction', 'the color', false, false); }