From 50baec90ec0ea3328d570bbc746126edeecf1e08 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 15:54:54 +0200 Subject: [PATCH 01/36] [task] migrate array utility --- Classes/Configuration/ConfigurationContainer.php | 2 +- Classes/Domain/Model/SearchRequest.php | 4 +++- Classes/Domain/Search/QueryFactory.php | 2 +- ext_localconf.php | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index eab76e0b..aaf0ebb7 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -21,7 +21,7 @@ */ use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Utility\ArrayUtility; +use TYPO3\CMS\Core\Utility\ArrayUtility; /** * Container of all configurations for extension. diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php index 3c888712..a375d24a 100644 --- a/Classes/Domain/Model/SearchRequest.php +++ b/Classes/Domain/Model/SearchRequest.php @@ -93,7 +93,9 @@ public function getSearchTerm() : string public function setFilter(array $filter) { $filter = \TYPO3\CMS\Core\Utility\ArrayUtility::removeArrayEntryByValue($filter, ''); - $this->filter = \TYPO3\CMS\Extbase\Utility\ArrayUtility::removeEmptyElementsRecursively($filter); + $this->filter = \TYPO3\CMS\Core\Utility\ArrayUtility::filterRecursive($filter, function ($value) { + return !empty($value); + }); } public function hasFilter() : bool diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php index 98e33247..a2f6c43f 100644 --- a/Classes/Domain/Search/QueryFactory.php +++ b/Classes/Domain/Search/QueryFactory.php @@ -25,7 +25,7 @@ use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\SearchRequestInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\ArrayUtility; +use TYPO3\CMS\Core\Utility\ArrayUtility; class QueryFactory { diff --git a/ext_localconf.php b/ext_localconf.php index 658d6834..810b3eb8 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -5,7 +5,7 @@ function ($extensionKey) { // TODO: Add hook for Extbase -> to handle records modified through // Frontend and backend modules not using datahandler - $GLOBALS['TYPO3_CONF_VARS'] = TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule( + \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule( $GLOBALS['TYPO3_CONF_VARS'], [ 'SC_OPTIONS' => [ @@ -43,7 +43,8 @@ function ($extensionKey) { \Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations(); // API does make use of object manager, therefore use GLOBALS - $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]); + $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extensionKey); + if ($extensionConfiguration === false || !isset($extensionConfiguration['disable.']['elasticsearch']) || $extensionConfiguration['disable.']['elasticsearch'] !== '1' From 0836c66cb3dcdbe69ee841dcbb25e3d990f82433 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 15:55:04 +0200 Subject: [PATCH 02/36] [task] remove no longer required like method --- Classes/Domain/Model/SearchRequest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php index a375d24a..2fb63306 100644 --- a/Classes/Domain/Model/SearchRequest.php +++ b/Classes/Domain/Model/SearchRequest.php @@ -217,11 +217,6 @@ public function equals($propertyName, $operand, $caseSensitive = true) throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); } - public function like($propertyName, $operand, $caseSensitive = true) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196167); - } - public function contains($propertyName, $operand) { throw new \BadMethodCallException('Method is not implemented yet.', 1502196200); From 3659a1558564bcd66bae739f0e7c3a0d60ca1162 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 15:55:29 +0200 Subject: [PATCH 03/36] [task] require legacy db because of huge refactoring of table service instead --- Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php | 3 +-- composer.json | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php index f4706138..01345e4e 100644 --- a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php +++ b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php @@ -21,12 +21,11 @@ */ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; -use Codappix\SearchCore\DataProcessing\CopyToProcessor; use Codappix\SearchCore\Domain\Index\TcaIndexer\RelationResolver; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService76; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService; use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; -use TYPO3\CMS\Core\Database\DatabaseConnection; +use TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection; class TcaTableServiceTest extends AbstractUnitTestCase { diff --git a/composer.json b/composer.json index 83e5f47b..3fac0b14 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "require": { "php": ">=7.0.0", "typo3/cms": ">= 7.6.0 < 9.0.0", - "ruflin/elastica": "~3.2" + "ruflin/elastica": "~3.2", + "friendsoftypo3/typo3db-legacy": "^1.1.1" }, "require-dev": { "phpunit/phpunit": "~6.4.4", From 09167c02ca5c8d26c70c74ec57cc2c4808f91047 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 15:58:10 +0200 Subject: [PATCH 04/36] [task] increase compatible typo3 version --- composer.json | 2 +- ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3fac0b14..9ed1894f 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=7.0.0", - "typo3/cms": ">= 7.6.0 < 9.0.0", + "typo3/cms": ">= 7.6.0 < 10.0.0", "ruflin/elastica": "~3.2", "friendsoftypo3/typo3db-legacy": "^1.1.1" }, diff --git a/ext_emconf.php b/ext_emconf.php index b0bc5ed9..be010dcf 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,7 +7,7 @@ 'clearCacheOnLoad' => 1, 'constraints' => [ 'depends' => [ - 'typo3' => '7.6.0-8.7.99', + 'typo3' => '7.6.0-9.5.99', 'php' => '7.0.0-7.2.99' ], 'conflicts' => [], From 01e2179b1422f6766a33b790d98db5639bf26cbb Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 16:24:18 +0200 Subject: [PATCH 05/36] [task] change requirement of typo3 cms core --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9ed1894f..94d01dc9 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=7.0.0", - "typo3/cms": ">= 7.6.0 < 10.0.0", + "typo3/cms-core": ">= 7.6.0 < 10.0.0", "ruflin/elastica": "~3.2", "friendsoftypo3/typo3db-legacy": "^1.1.1" }, From 5ea0f34632b301baac4231574e193e2f5b9bd5fc Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Wed, 17 Oct 2018 17:17:06 +0200 Subject: [PATCH 06/36] =?UTF-8?q?[task]=C2=A0handle=20missing=20array=20pa?= =?UTF-8?q?th=20exceptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Configuration/ConfigurationContainer.php | 21 +++++++++++++------ .../Connection/Elasticsearch/Connection.php | 5 +++-- Classes/Domain/Index/IndexerFactory.php | 3 +++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index aaf0ebb7..9dd954f5 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -20,6 +20,7 @@ * 02110-1301, USA. */ +use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; @@ -60,16 +61,17 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config */ public function get(string $path) { - $value = ArrayUtility::getValueByPath($this->settings, $path); - - if ($value === null) { + try + { + return ArrayUtility::getValueByPath($this->settings, $path); + } + catch (MissingArrayPathException $exception) + { throw new InvalidArgumentException( 'The given configuration option "' . $path . '" does not exist.', InvalidArgumentException::OPTION_DOES_NOT_EXIST ); } - - return $value; } /** @@ -78,6 +80,13 @@ public function get(string $path) */ public function getIfExists(string $path) { - return ArrayUtility::getValueByPath($this->settings, $path); + try + { + return ArrayUtility::getValueByPath($this->settings, $path); + } + catch (\Exception $exception) + { + return null; + } } } diff --git a/Classes/Connection/Elasticsearch/Connection.php b/Classes/Connection/Elasticsearch/Connection.php index a5e7d0f7..a51b943e 100644 --- a/Classes/Connection/Elasticsearch/Connection.php +++ b/Classes/Connection/Elasticsearch/Connection.php @@ -22,6 +22,7 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use TYPO3\CMS\Core\SingletonInterface as Singleton; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * The current connection to elasticsearch. @@ -54,8 +55,8 @@ public function __construct( if ($elasticaClient === null) { $elasticaClient = new \Elastica\Client([ - 'host' => $this->configuration->get('connections.elasticsearch.host'), - 'port' => $this->configuration->get('connections.elasticsearch.port'), + 'host' => $this->configuration->getIfExists('connections.elasticsearch.host'), + 'port' => $this->configuration->getIfExists('connections.elasticsearch.port'), // TODO: Make configurable // 'log' => 'file', ]); diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index 668111d9..f59632fa 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -25,6 +25,7 @@ use Codappix\SearchCore\Domain\Index\IndexerInterface; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; use TYPO3\CMS\Core\SingletonInterface as Singleton; +use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; /** @@ -65,6 +66,8 @@ public function getIndexer(string $identifier) : IndexerInterface // Nothing to do, we throw exception below } catch (InvalidArgumentException $e) { // Nothing to do, we throw exception below + } catch (MissingArrayPathException $e) { + // Nothing to do, we throw exception below } throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442); From f936d1f7c598e16b0b9efdba129ba0bce97c525f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20So=CC=88lch?= Date: Thu, 18 Oct 2018 11:56:22 +0200 Subject: [PATCH 07/36] [TASK] remove dblegacy --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 94d01dc9..37e9e07c 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "require": { "php": ">=7.0.0", "typo3/cms-core": ">= 7.6.0 < 10.0.0", - "ruflin/elastica": "~3.2", - "friendsoftypo3/typo3db-legacy": "^1.1.1" + "ruflin/elastica": "~3.2" }, "require-dev": { "phpunit/phpunit": "~6.4.4", From 0a9cdd5dce12c97e17ae8e989b2c0ec6fcc15118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20So=CC=88lch?= Date: Thu, 18 Oct 2018 15:21:25 +0200 Subject: [PATCH 08/36] [TASK] bugfixes and error removal --- .../Configuration/ConfigurationContainer.php | 12 +- Classes/Domain/Index/AbstractIndexer.php | 108 ++++++++++++------ ext_localconf.php | 7 +- 3 files changed, 83 insertions(+), 44 deletions(-) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index aaf0ebb7..aab35d9b 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -20,8 +20,10 @@ * 02110-1301, USA. */ +use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * Container of all configurations for extension. @@ -60,8 +62,8 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config */ public function get(string $path) { - $value = ArrayUtility::getValueByPath($this->settings, $path); - + $value = ArrayUtility::getValueByPath($this->settings, $path, '.'); + if ($value === null) { throw new InvalidArgumentException( 'The given configuration option "' . $path . '" does not exist.', @@ -78,6 +80,10 @@ public function get(string $path) */ public function getIfExists(string $path) { - return ArrayUtility::getValueByPath($this->settings, $path); + try { + return ArrayUtility::getValueByPath($this->settings, $path, '.'); + } catch (MissingArrayPathException $exception) { + return null; + } } } diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index b22c0110..47459b01 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -1,4 +1,5 @@ logger = $logManager->getLogger(__CLASS__); } - + public function setIdentifier(string $identifier) { $this->identifier = $identifier; } - + public function __construct(ConnectionInterface $connection, ConfigurationContainerInterface $configuration) { $this->connection = $connection; $this->configuration = $configuration; } - + public function indexAllDocuments() { $this->logger->info('Start indexing'); @@ -81,24 +84,24 @@ public function indexAllDocuments() if ($records === null) { break; } - + foreach ($records as &$record) { $this->prepareRecord($record); } - + $this->logger->debug('Index records.', [$records]); $this->connection->addDocuments($this->getDocumentName(), $records); } $this->logger->info('Finish indexing'); } - + public function indexDocument(string $identifier) { $this->logger->info('Start indexing single record.', [$identifier]); try { - $record = $this->getRecord((int) $identifier); + $record = $this->getRecord((int)$identifier); $this->prepareRecord($record); - + $this->connection->addDocument($this->getDocumentName(), $record); } catch (NoRecordFoundException $e) { $this->logger->info('Could not index document. Try to delete it therefore.', [$e->getMessage()]); @@ -106,47 +109,70 @@ public function indexDocument(string $identifier) } $this->logger->info('Finish indexing'); } - + public function delete() { $this->logger->info('Start deletion of index.'); $this->connection->deleteIndex($this->getDocumentName()); $this->logger->info('Finish deletion.'); } - - protected function getRecordGenerator() : \Generator + + protected function getRecordGenerator(): \Generator { $offset = 0; $limit = $this->getLimit(); - + while (($records = $this->getRecords($offset, $limit)) !== []) { yield $records; $offset += $limit; } } - + + + /** + * @param array $record + * + * @throws \Exception + */ protected function prepareRecord(array &$record) { try { - foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) { - $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier); + $indexingConfiguration = $this->configuration->get('indexing.' . $this->identifier . '.dataProcessing'); + + if (!empty($indexingConfiguration) && is_array($indexingConfiguration)) { + foreach ($indexingConfiguration as $configuration) { + $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, + $this->identifier); + } + } + } catch (\Exception $e) { + if ($e instanceof InvalidArgumentException) { + // Nothing to do + } elseif ($e instanceof MissingArrayPathException) { + // Nothing to do + } else { + throw $e; } - } catch (InvalidArgumentException $e) { - // Nothing to do. } - + $this->handleAbstract($record); } - + + + /** + * @param array $record + * + * @throws \Exception + */ protected function handleAbstract(array &$record) { $record['search_abstract'] = ''; - + try { - $fieldsToUse = GeneralUtility::trimExplode( - ',', - $this->configuration->get('indexing.' . $this->identifier . '.abstractFields') - ); + + $indexConfiguration = $this->configuration->get('indexing.' . $this->identifier . '.abstractFields'); + + $fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration); if ($fieldsToUse === []) { return; } @@ -156,29 +182,35 @@ protected function handleAbstract(array &$record) break; } } - } catch (InvalidArgumentException $e) { - return; + } catch (\Exception $e) { + if ($e instanceof InvalidArgumentException) { + return; + } elseif ($e instanceof MissingArrayPathException) { + return; + } else { + throw $e; + } } } - + /** * Returns the limit to use to fetch records. */ - protected function getLimit() : int + protected function getLimit(): int { // TODO: Make configurable. return 50; } - + /** * @return array|null */ abstract protected function getRecords(int $offset, int $limit); - + /** * @throws NoRecordFoundException If record could not be found. */ - abstract protected function getRecord(int $identifier) : array; - - abstract protected function getDocumentName() : string; + abstract protected function getRecord(int $identifier): array; + + abstract protected function getDocumentName(): string; } diff --git a/ext_localconf.php b/ext_localconf.php index 810b3eb8..2d900a04 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -42,12 +42,13 @@ function ($extensionKey) { \Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations(); + // API does make use of object manager, therefore use GLOBALS $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extensionKey); - + if ($extensionConfiguration === false - || !isset($extensionConfiguration['disable.']['elasticsearch']) - || $extensionConfiguration['disable.']['elasticsearch'] !== '1' + || !isset($extensionConfiguration['disable']['elasticsearch']) + || $extensionConfiguration['disable']['elasticsearch'] !== '1' ) { \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class) ->registerImplementation( From fd78867b40e348e3386ea3843fdde035eea41df0 Mon Sep 17 00:00:00 2001 From: Martin Hummer Date: Mon, 22 Oct 2018 13:34:26 +0200 Subject: [PATCH 09/36] Add missing return statement --- Classes/Configuration/ConfigurationContainer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index 1ebe8246..4fd4fccc 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -70,6 +70,8 @@ public function get(string $path) InvalidArgumentException::OPTION_DOES_NOT_EXIST ); } + + return $value; } /** From 94be3ca84703cbeee07b5623da7c0fe2c832a94c Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 10:21:34 +0100 Subject: [PATCH 10/36] [task] update version constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 37e9e07c..aeb55527 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=7.0.0", - "typo3/cms-core": ">= 7.6.0 < 10.0.0", + "typo3/cms-core": ">= 8.7.0 < 10.0.0", "ruflin/elastica": "~3.2" }, "require-dev": { From 690e6a431d3eb1e362743bd8ec57bc2933791297 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 11:13:21 +0100 Subject: [PATCH 11/36] [task] drop typo3 7.6 --- .../ImplementationRegistrationService.php | 30 +- Classes/Compatibility/TypoScriptService76.php | 31 -- .../Index/TcaIndexer/TcaTableService76.php | 378 ------------------ 3 files changed, 10 insertions(+), 429 deletions(-) delete mode 100644 Classes/Compatibility/TypoScriptService76.php delete mode 100644 Classes/Domain/Index/TcaIndexer/TcaTableService76.php diff --git a/Classes/Compatibility/ImplementationRegistrationService.php b/Classes/Compatibility/ImplementationRegistrationService.php index fa3faa83..58d8aa6d 100644 --- a/Classes/Compatibility/ImplementationRegistrationService.php +++ b/Classes/Compatibility/ImplementationRegistrationService.php @@ -21,7 +21,6 @@ */ use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\Container\Container; /** @@ -33,24 +32,15 @@ class ImplementationRegistrationService public static function registerImplementations() { $container = GeneralUtility::makeInstance(Container::class); - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $container->registerImplementation( - \Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class, - \Codappix\SearchCore\Compatibility\TypoScriptService::class - ); - $container->registerImplementation( - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class, - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService::class - ); - } else { - $container->registerImplementation( - \Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class, - \Codappix\SearchCore\Compatibility\TypoScriptService76::class - ); - $container->registerImplementation( - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class, - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService76::class - ); - } + + $container->registerImplementation( + \Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class, + \Codappix\SearchCore\Compatibility\TypoScriptService::class + ); + + $container->registerImplementation( + \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class, + \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService::class + ); } } diff --git a/Classes/Compatibility/TypoScriptService76.php b/Classes/Compatibility/TypoScriptService76.php deleted file mode 100644 index 9df82ea4..00000000 --- a/Classes/Compatibility/TypoScriptService76.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use TYPO3\CMS\Extbase\Service\TypoScriptService as CoreTypoScriptService; - -/** - * Used before TYPO3 CMS 8.7. - */ -class TypoScriptService76 extends CoreTypoScriptService implements TypoScriptServiceInterface -{ - -} diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php b/Classes/Domain/Index/TcaIndexer/TcaTableService76.php deleted file mode 100644 index 4445d6d0..00000000 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php +++ /dev/null @@ -1,378 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; -use Codappix\SearchCore\Domain\Index\IndexingException; -use Codappix\SearchCore\Domain\Index\TcaIndexer\InvalidArgumentException; -use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\RootlineUtility; -use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; - -/** - * Encapsulate logik related to TCA configuration. - */ -class TcaTableService76 implements TcaTableServiceInterface -{ - /** - * TCA for current table. - * !REFERENCE! To save memory. - * @var array - */ - protected $tca; - - /** - * @var string - */ - protected $tableName; - - /** - * @var ConfigurationContainerInterface - */ - protected $configuration; - - /** - * @var \TYPO3\CMS\Core\Log\Logger - */ - protected $logger; - - /** - * @var ObjectManagerInterface - */ - protected $objectManager; - - /** - * Inject log manager to get concrete logger from it. - * - * @param \TYPO3\CMS\Core\Log\LogManager $logManager - */ - public function injectLogger(\TYPO3\CMS\Core\Log\LogManager $logManager) - { - $this->logger = $logManager->getLogger(__CLASS__); - } - - /** - * @param ObjectManagerInterface $objectManager - */ - public function injectObjectManager(ObjectManagerInterface $objectManager) - { - $this->objectManager = $objectManager; - } - - /** - * @param string $tableName - * @param ConfigurationContainerInterface $configuration - */ - public function __construct( - $tableName, - ConfigurationContainerInterface $configuration - ) { - if (!isset($GLOBALS['TCA'][$tableName])) { - throw new IndexingException( - 'Table "' . $tableName . '" is not configured in TCA.', - IndexingException::CODE_UNKOWN_TCA_TABLE - ); - } - - $this->tableName = $tableName; - $this->tca = &$GLOBALS['TCA'][$this->tableName]; - $this->configuration = $configuration; - } - - public function getTableName() : string - { - return $this->tableName; - } - - public function getTableClause() : string - { - if ($this->tableName === 'pages') { - return $this->tableName; - } - - return $this->tableName . ' LEFT JOIN pages on ' . $this->tableName . '.pid = pages.uid'; - } - - public function getRecords(int $offset, int $limit) : array - { - $records = $this->getConnection()->exec_SELECTgetRows( - $this->getFields(), - $this->getTableClause(), - $this->getWhereClause(), - '', - '', - (int) $offset . ',' . (int) $limit - ); - - return $records ?: []; - } - - public function getRecord(int $identifier) : array - { - $record = $this->getConnection()->exec_SELECTgetSingleRow( - $this->getFields(), - $this->getTableClause(), - $this->getWhereClause() - . ' AND ' . $this->getTableName() . '.uid = ' . (int) $identifier - ); - - return $record ?: []; - } - - public function filterRecordsByRootLineBlacklist(array &$records) - { - $records = array_filter( - $records, - function ($record) { - return ! $this->isRecordBlacklistedByRootline($record); - } - ); - } - - public function prepareRecord(array &$record) - { - if (isset($record['uid']) && !isset($record['search_identifier'])) { - $record['search_identifier'] = $record['uid']; - } - if (isset($record[$this->tca['ctrl']['label']]) && !isset($record['search_title'])) { - $record['search_title'] = $record[$this->tca['ctrl']['label']]; - } - } - - public function getWhereClause() : string - { - $whereClause = '1=1' - . BackendUtility::BEenableFields($this->tableName) - . BackendUtility::deleteClause($this->tableName) - . ' AND pages.no_search = 0' - ; - - if ($this->tableName !== 'pages') { - $whereClause .= BackendUtility::BEenableFields('pages') - . BackendUtility::deleteClause('pages') - ; - } - - $userDefinedWhere = $this->configuration->getIfExists( - 'indexing.' . $this->getTableName() . '.additionalWhereClause' - ); - if (is_string($userDefinedWhere)) { - $whereClause .= ' AND ' . $userDefinedWhere; - } - if ($this->isBlacklistedRootLineConfigured()) { - $whereClause .= ' AND pages.uid NOT IN (' - . implode(',', $this->getBlacklistedRootLine()) - . ')' - . ' AND pages.pid NOT IN (' - . implode(',', $this->getBlacklistedRootLine()) - . ')'; - } - - $this->logger->debug('Generated where clause.', [$this->tableName, $whereClause]); - return $whereClause; - } - - public function getFields() : string - { - $fields = array_merge( - ['uid','pid'], - array_filter( - array_keys($this->tca['columns']), - function ($columnName) { - return !$this->isSystemField($columnName) - && !$this->isUserField($columnName) - && !$this->isPassthroughField($columnName) - ; - } - ) - ); - - foreach ($fields as $key => $field) { - $fields[$key] = $this->tableName . '.' . $field; - } - - $this->logger->debug('Generated fields.', [$this->tableName, $fields]); - return implode(',', $fields); - } - - - /** - * Generate SQL for TYPO3 as a system, to make sure only available records - * are fetched. - */ - protected function getSystemWhereClause() : string - { - $whereClause = '1=1' - . BackendUtility::BEenableFields($this->tableName) - . BackendUtility::deleteClause($this->tableName) - . ' AND pages.no_search = 0' - ; - - if ($this->tableName !== 'pages') { - $whereClause .= BackendUtility::BEenableFields('pages') - . BackendUtility::deleteClause('pages') - ; - } - - return $whereClause; - } - - protected function isSystemField(string $columnName) : bool - { - $systemFields = [ - // Versioning fields, - // https://docs.typo3.org/typo3cms/TCAReference/Reference/Ctrl/Index.html#versioningws - 't3ver_oid', 't3ver_id', 't3ver_label', 't3ver_wsid', - 't3ver_state', 't3ver_stage', 't3ver_count', 't3ver_tstamp', - 't3ver_move_id', 't3ver_swapmode', - $this->tca['ctrl']['transOrigDiffSourceField'], - $this->tca['ctrl']['cruser_id'], - $this->tca['ctrl']['fe_cruser_id'], - $this->tca['ctrl']['fe_crgroup_id'], - $this->tca['ctrl']['origUid'], - ]; - - return in_array($columnName, $systemFields); - } - - protected function isUserField(string $columnName) : bool - { - $config = $this->getColumnConfig($columnName); - return isset($config['type']) && $config['type'] === 'user'; - } - - protected function isPassthroughField(string $columnName) : bool - { - $config = $this->getColumnConfig($columnName); - return isset($config['type']) && $config['type'] === 'passthrough'; - } - - /** - * @throws InvalidArgumentException - */ - public function getColumnConfig(string $columnName) : array - { - if (!isset($this->tca['columns'][$columnName])) { - throw new InvalidArgumentException( - 'Column does not exist.', - InvalidArgumentException::COLUMN_DOES_NOT_EXIST - ); - } - - return $this->tca['columns'][$columnName]['config']; - } - - public function getLanguageUidColumn() : string - { - if (!isset($this->tca['ctrl']['languageField'])) { - return ''; - } - - return $this->tca['ctrl']['languageField']; - } - - /** - * Checks whether the given record was blacklisted by root line. - * This can be configured by typoscript as whole root lines can be black listed. - * - * Also further TYPO3 mechanics are taken into account. Does a valid root - * line exist, is page inside a recycler, is inherited start- endtime - * excluded, etc. - */ - protected function isRecordBlacklistedByRootline(array &$record) : bool - { - $pageUid = $record['pid']; - if ($this->tableName === 'pages') { - $pageUid = $record['uid']; - } - - try { - $rootline = $this->objectManager->get(RootlineUtility::class, $pageUid)->get(); - } catch (\RuntimeException $e) { - $this->logger->notice( - sprintf('Could not fetch rootline for page %u, because: %s', $pageUid, $e->getMessage()), - [$record, $e] - ); - return true; - } - - foreach ($rootline as $pageInRootLine) { - // Check configured black list if present. - if ($this->isBlackListedRootLineConfigured() - && in_array($pageInRootLine['uid'], $this->getBlackListedRootLine()) - ) { - $this->logger->info( - sprintf( - 'Record %u is black listed due to configured root line configuration of page %u.', - $record['uid'], - $pageInRootLine['uid'] - ), - [$record, $pageInRootLine] - ); - return true; - } - - if ($pageInRootLine['extendToSubpages'] && ( - ($pageInRootLine['endtime'] > 0 && $pageInRootLine['endtime'] <= time()) - || ($pageInRootLine['starttime'] > 0 && $pageInRootLine['starttime'] >= time()) - )) { - $this->logger->info( - sprintf( - 'Record %u is black listed due to configured timing of parent page %u.', - $record['uid'], - $pageInRootLine['uid'] - ), - [$record, $pageInRootLine] - ); - return true; - } - } - - return false; - } - - /** - * Checks whether any page uids are black listed. - */ - protected function isBlackListedRootLineConfigured() : bool - { - return (bool) $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.rootLineBlacklist'); - } - - /** - * Get the list of black listed root line page uids. - * - * @return array - */ - protected function getBlackListedRootLine() : array - { - return GeneralUtility::intExplode( - ',', - $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.rootLineBlacklist') - ); - } - - protected function getConnection() : \TYPO3\CMS\Core\Database\DatabaseConnection - { - return $GLOBALS['TYPO3_DB']; - } -} From fa74af32615b299d8802553b9d622049f90e909a Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 11:13:56 +0100 Subject: [PATCH 12/36] [task] implement extension configuration interface --- Classes/Bootstrap.php | 17 +++++++ .../ImplementationRegistrationService.php | 46 +++++++++++++++---- Classes/Utility/ExtensionConfiguration.php | 7 +++ Classes/Utility/ExtensionConfiguration87.php | 11 +++++ .../ExtensionConfigurationInterface.php | 8 ++++ ext_localconf.php | 6 +-- 6 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 Classes/Bootstrap.php create mode 100644 Classes/Utility/ExtensionConfiguration.php create mode 100644 Classes/Utility/ExtensionConfiguration87.php create mode 100644 Classes/Utility/ExtensionConfigurationInterface.php diff --git a/Classes/Bootstrap.php b/Classes/Bootstrap.php new file mode 100644 index 00000000..b156a28a --- /dev/null +++ b/Classes/Bootstrap.php @@ -0,0 +1,17 @@ +registerImplementation( - \Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class, - \Codappix\SearchCore\Compatibility\TypoScriptService::class - ); + if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 9000000) { + $container->registerImplementation( + ExtensionConfigurationInterface::class, + ExtensionConfiguration::class + ); + + $container->registerImplementation( + TypoScriptServiceInterface::class, + TypoScriptService::class + ); + + $container->registerImplementation( + TcaTableServiceInterface::class, + TcaTableService::class + ); + } else if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { + $container->registerImplementation( + ExtensionConfigurationInterface::class, + ExtensionConfiguration87::class + ); + + $container->registerImplementation( + TypoScriptServiceInterface::class, + TypoScriptService::class + ); - $container->registerImplementation( - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class, - \Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService::class - ); + $container->registerImplementation( + TcaTableServiceInterface::class, + TcaTableService::class + ); + } } } diff --git a/Classes/Utility/ExtensionConfiguration.php b/Classes/Utility/ExtensionConfiguration.php new file mode 100644 index 00000000..029cd3c4 --- /dev/null +++ b/Classes/Utility/ExtensionConfiguration.php @@ -0,0 +1,7 @@ +get($extensionKey); - + $extensionConfiguration = \Codappix\SearchCore\Bootstrap::getObjectManager()->get(\Codappix\SearchCore\Utility\ExtensionConfigurationInterface::class)->get($extensionKey); + if ($extensionConfiguration === false || !isset($extensionConfiguration['disable']['elasticsearch']) || $extensionConfiguration['disable']['elasticsearch'] !== '1' From d1607ac1b4288d20255507429f982d7ba8a1e09a Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 11:30:06 +0100 Subject: [PATCH 13/36] [task] resturcture compatibility layer --- Classes/Bootstrap.php | 11 +++++++++++ .../ExtensionConfiguration.php | 2 +- .../ExtensionConfigurationInterface.php | 2 +- .../ImplementationRegistrationService.php | 6 ++---- .../Version87/ExtensionConfiguration.php | 13 +++++++++++++ Classes/Utility/ExtensionConfiguration87.php | 11 ----------- ext_localconf.php | 2 +- 7 files changed, 29 insertions(+), 18 deletions(-) rename Classes/{Utility => Compatibility}/ExtensionConfiguration.php (76%) rename Classes/{Utility => Compatibility}/ExtensionConfigurationInterface.php (67%) create mode 100644 Classes/Compatibility/Version87/ExtensionConfiguration.php delete mode 100644 Classes/Utility/ExtensionConfiguration87.php diff --git a/Classes/Bootstrap.php b/Classes/Bootstrap.php index b156a28a..ecfb784b 100644 --- a/Classes/Bootstrap.php +++ b/Classes/Bootstrap.php @@ -2,6 +2,7 @@ namespace Codappix\SearchCore; +use Codappix\SearchCore\Compatibility\ExtensionConfigurationInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -14,4 +15,14 @@ public static function getObjectManager() { return GeneralUtility::makeInstance(ObjectManager::class); } + + /** + * @return ExtensionConfigurationInterface + */ + public static function getExtensionConfiguration() + { + return static::getObjectManager()->get( + ExtensionConfigurationInterface::class + ); + } } \ No newline at end of file diff --git a/Classes/Utility/ExtensionConfiguration.php b/Classes/Compatibility/ExtensionConfiguration.php similarity index 76% rename from Classes/Utility/ExtensionConfiguration.php rename to Classes/Compatibility/ExtensionConfiguration.php index 029cd3c4..84a65099 100644 --- a/Classes/Utility/ExtensionConfiguration.php +++ b/Classes/Compatibility/ExtensionConfiguration.php @@ -1,6 +1,6 @@ = 8000000) { $container->registerImplementation( ExtensionConfigurationInterface::class, - ExtensionConfiguration87::class + Version87\ExtensionConfiguration::class ); $container->registerImplementation( diff --git a/Classes/Compatibility/Version87/ExtensionConfiguration.php b/Classes/Compatibility/Version87/ExtensionConfiguration.php new file mode 100644 index 00000000..86814fa1 --- /dev/null +++ b/Classes/Compatibility/Version87/ExtensionConfiguration.php @@ -0,0 +1,13 @@ +get(\Codappix\SearchCore\Utility\ExtensionConfigurationInterface::class)->get($extensionKey); + $extensionConfiguration = \Codappix\SearchCore\Bootstrap::getExtensionConfiguration()->get($extensionKey); if ($extensionConfiguration === false || !isset($extensionConfiguration['disable']['elasticsearch']) From fbaa555b96d69cd22abe04091962dd4f506941ec Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 11:46:21 +0100 Subject: [PATCH 14/36] [task] catch wrong exceptions when accessing configuration --- Classes/Domain/Index/AbstractIndexer.php | 4 ++-- Classes/Domain/Index/IndexerFactory.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 47459b01..861c17a3 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -137,7 +137,7 @@ protected function getRecordGenerator(): \Generator protected function prepareRecord(array &$record) { try { - $indexingConfiguration = $this->configuration->get('indexing.' . $this->identifier . '.dataProcessing'); + $indexingConfiguration = $this->configuration->getIfExists('indexing.' . $this->identifier . '.dataProcessing'); if (!empty($indexingConfiguration) && is_array($indexingConfiguration)) { foreach ($indexingConfiguration as $configuration) { @@ -170,7 +170,7 @@ protected function handleAbstract(array &$record) try { - $indexConfiguration = $this->configuration->get('indexing.' . $this->identifier . '.abstractFields'); + $indexConfiguration = $this->configuration->getIfExists('indexing.' . $this->identifier . '.abstractFields'); $fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration); if ($fieldsToUse === []) { diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index f59632fa..c7308542 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -68,6 +68,8 @@ public function getIndexer(string $identifier) : IndexerInterface // Nothing to do, we throw exception below } catch (MissingArrayPathException $e) { // Nothing to do, we throw exception below + } catch (\RuntimeException $exception) { + // Nothing to do, we throw exception below } throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442); From 4606d7649eba2989a1af939f83a1d978569dd4fc Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 12:56:32 +0100 Subject: [PATCH 15/36] [task] dont define multiple implementations with same class --- .../ImplementationRegistrationService.php | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/Classes/Compatibility/ImplementationRegistrationService.php b/Classes/Compatibility/ImplementationRegistrationService.php index f34d6d7b..223e8584 100644 --- a/Classes/Compatibility/ImplementationRegistrationService.php +++ b/Classes/Compatibility/ImplementationRegistrationService.php @@ -26,7 +26,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\Container\Container; -use TYPO3\CMS\Extbase\Persistence\Generic\Qom\Comparison; /** * Register different concrete implementations, depending on current TYPO3 version. @@ -44,31 +43,21 @@ public static function registerImplementations() ExtensionConfigurationInterface::class, ExtensionConfiguration::class ); - - $container->registerImplementation( - TypoScriptServiceInterface::class, - TypoScriptService::class - ); - - $container->registerImplementation( - TcaTableServiceInterface::class, - TcaTableService::class - ); } else if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { $container->registerImplementation( ExtensionConfigurationInterface::class, Version87\ExtensionConfiguration::class ); + } - $container->registerImplementation( - TypoScriptServiceInterface::class, - TypoScriptService::class - ); + $container->registerImplementation( + TypoScriptServiceInterface::class, + TypoScriptService::class + ); - $container->registerImplementation( - TcaTableServiceInterface::class, - TcaTableService::class - ); - } + $container->registerImplementation( + TcaTableServiceInterface::class, + TcaTableService::class + ); } } From 5acdd918653597cd267dceeff9f4fc60c34c9d55 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Tue, 30 Oct 2018 13:02:34 +0100 Subject: [PATCH 16/36] [fix] v9 compatible extension configuration implementation --- .../Compatibility/ExtensionConfiguration.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Classes/Compatibility/ExtensionConfiguration.php b/Classes/Compatibility/ExtensionConfiguration.php index 84a65099..3cb42141 100644 --- a/Classes/Compatibility/ExtensionConfiguration.php +++ b/Classes/Compatibility/ExtensionConfiguration.php @@ -2,6 +2,26 @@ namespace Codappix\SearchCore\Compatibility; -class ExtensionConfiguration extends \TYPO3\CMS\Core\Configuration\ExtensionConfiguration implements ExtensionConfigurationInterface +use Codappix\SearchCore\Bootstrap; + +class ExtensionConfiguration implements ExtensionConfigurationInterface { -} \ No newline at end of file + /** + * @return object|\TYPO3\CMS\Core\Configuration\ExtensionConfiguration + */ + protected function _base() + { + return Bootstrap::getObjectManager()->get(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class); + } + + /** + * @param $extensionKey + * @return mixed + * @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException + * @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException + */ + public function get($extensionKey) + { + return $this->_base()->get($extensionKey); + } +} From c940ac44971e0ad764ee080f0b2b44c2efbe4472 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 09:53:00 +0200 Subject: [PATCH 17/36] Fix CGL issues Do not introduce unnecessary changes into pull request for TYPO3 CMS 9 update. * Trim trailing whitespace. * Do not introduce blank line before namespace definition with this pull request. * Add posix new line at end of file. --- Classes/Bootstrap.php | 3 +- .../Compatibility/ExtensionConfiguration.php | 5 +- .../ExtensionConfigurationInterface.php | 3 +- .../ImplementationRegistrationService.php | 3 +- .../Version87/ExtensionConfiguration.php | 2 +- .../Configuration/ConfigurationContainer.php | 11 ++- Classes/Domain/Index/AbstractIndexer.php | 69 ++++++++++--------- 7 files changed, 46 insertions(+), 50 deletions(-) diff --git a/Classes/Bootstrap.php b/Classes/Bootstrap.php index ecfb784b..0cd8a890 100644 --- a/Classes/Bootstrap.php +++ b/Classes/Bootstrap.php @@ -1,5 +1,4 @@ get(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class); } @@ -22,6 +21,6 @@ protected function _base() */ public function get($extensionKey) { - return $this->_base()->get($extensionKey); + return $this->base()->get($extensionKey); } } diff --git a/Classes/Compatibility/ExtensionConfigurationInterface.php b/Classes/Compatibility/ExtensionConfigurationInterface.php index d12ccd3b..f62ab2d3 100644 --- a/Classes/Compatibility/ExtensionConfigurationInterface.php +++ b/Classes/Compatibility/ExtensionConfigurationInterface.php @@ -1,8 +1,7 @@ = 8000000) { + } elseif (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { $container->registerImplementation( ExtensionConfigurationInterface::class, Version87\ExtensionConfiguration::class diff --git a/Classes/Compatibility/Version87/ExtensionConfiguration.php b/Classes/Compatibility/Version87/ExtensionConfiguration.php index 86814fa1..6ff91afb 100644 --- a/Classes/Compatibility/Version87/ExtensionConfiguration.php +++ b/Classes/Compatibility/Version87/ExtensionConfiguration.php @@ -10,4 +10,4 @@ public function get($extensionKey) { return unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]); } -} \ No newline at end of file +} diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index 4fd4fccc..4a937306 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -63,14 +63,14 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config public function get(string $path) { $value = ArrayUtility::getValueByPath($this->settings, $path, '.'); - + if ($value === null) { throw new InvalidArgumentException( 'The given configuration option "' . $path . '" does not exist.', InvalidArgumentException::OPTION_DOES_NOT_EXIST ); } - + return $value; } @@ -80,12 +80,9 @@ public function get(string $path) */ public function getIfExists(string $path) { - try - { + try { return ArrayUtility::getValueByPath($this->settings, $path, '.'); - } - catch (\Exception $exception) - { + } catch (\Exception $exception) { return null; } } diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 861c17a3..a6a89466 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -1,5 +1,4 @@ logger = $logManager->getLogger(__CLASS__); } - + public function setIdentifier(string $identifier) { $this->identifier = $identifier; } - + public function __construct(ConnectionInterface $connection, ConfigurationContainerInterface $configuration) { $this->connection = $connection; $this->configuration = $configuration; } - + public function indexAllDocuments() { $this->logger->info('Start indexing'); @@ -84,24 +83,24 @@ public function indexAllDocuments() if ($records === null) { break; } - + foreach ($records as &$record) { $this->prepareRecord($record); } - + $this->logger->debug('Index records.', [$records]); $this->connection->addDocuments($this->getDocumentName(), $records); } $this->logger->info('Finish indexing'); } - + public function indexDocument(string $identifier) { $this->logger->info('Start indexing single record.', [$identifier]); try { $record = $this->getRecord((int)$identifier); $this->prepareRecord($record); - + $this->connection->addDocument($this->getDocumentName(), $record); } catch (NoRecordFoundException $e) { $this->logger->info('Could not index document. Try to delete it therefore.', [$e->getMessage()]); @@ -109,26 +108,25 @@ public function indexDocument(string $identifier) } $this->logger->info('Finish indexing'); } - + public function delete() { $this->logger->info('Start deletion of index.'); $this->connection->deleteIndex($this->getDocumentName()); $this->logger->info('Finish deletion.'); } - + protected function getRecordGenerator(): \Generator { $offset = 0; $limit = $this->getLimit(); - + while (($records = $this->getRecords($offset, $limit)) !== []) { yield $records; $offset += $limit; } } - - + /** * @param array $record * @@ -137,12 +135,17 @@ protected function getRecordGenerator(): \Generator protected function prepareRecord(array &$record) { try { - $indexingConfiguration = $this->configuration->getIfExists('indexing.' . $this->identifier . '.dataProcessing'); - + $indexingConfiguration = $this->configuration->getIfExists( + 'indexing.' . $this->identifier . '.dataProcessing' + ); + if (!empty($indexingConfiguration) && is_array($indexingConfiguration)) { foreach ($indexingConfiguration as $configuration) { - $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, - $this->identifier); + $record = $this->dataProcessorService->executeDataProcessor( + $configuration, + $record, + $this->identifier + ); } } } catch (\Exception $e) { @@ -154,11 +157,10 @@ protected function prepareRecord(array &$record) throw $e; } } - + $this->handleAbstract($record); } - - + /** * @param array $record * @@ -167,11 +169,12 @@ protected function prepareRecord(array &$record) protected function handleAbstract(array &$record) { $record['search_abstract'] = ''; - + try { - - $indexConfiguration = $this->configuration->getIfExists('indexing.' . $this->identifier . '.abstractFields'); - + $indexConfiguration = $this->configuration->getIfExists( + 'indexing.' . $this->identifier . '.abstractFields' + ); + $fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration); if ($fieldsToUse === []) { return; @@ -192,7 +195,7 @@ protected function handleAbstract(array &$record) } } } - + /** * Returns the limit to use to fetch records. */ @@ -201,16 +204,16 @@ protected function getLimit(): int // TODO: Make configurable. return 50; } - + /** * @return array|null */ abstract protected function getRecords(int $offset, int $limit); - + /** * @throws NoRecordFoundException If record could not be found. */ abstract protected function getRecord(int $identifier): array; - + abstract protected function getDocumentName(): string; } From 2b91425732630f3f6f8fe96f0e3da753251beaf1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:11:09 +0200 Subject: [PATCH 18/36] Remove unused debugger imports --- Classes/Configuration/ConfigurationContainer.php | 1 - Classes/Connection/Elasticsearch/Connection.php | 1 - 2 files changed, 2 deletions(-) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index 4a937306..79227d52 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * Container of all configurations for extension. diff --git a/Classes/Connection/Elasticsearch/Connection.php b/Classes/Connection/Elasticsearch/Connection.php index a51b943e..a1ea999f 100644 --- a/Classes/Connection/Elasticsearch/Connection.php +++ b/Classes/Connection/Elasticsearch/Connection.php @@ -22,7 +22,6 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use TYPO3\CMS\Core\SingletonInterface as Singleton; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * The current connection to elasticsearch. From 5779cb911d679b88c79cb88be383898a334e7991 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:12:13 +0200 Subject: [PATCH 19/36] Revert changes to configuration fetching Keep old code and behaviour. Adjust only a single place to keep old expected behaviour. If TYPO3 throws an exception, catch this, and replace it by old behaviour which is already handled throughout the code. --- .../Configuration/ConfigurationContainer.php | 7 ++- .../Connection/Elasticsearch/Connection.php | 4 +- Classes/Domain/Index/AbstractIndexer.php | 51 ++++--------------- Classes/Domain/Index/IndexerFactory.php | 5 -- 4 files changed, 16 insertions(+), 51 deletions(-) diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index 79227d52..764e91ad 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -20,7 +20,6 @@ * 02110-1301, USA. */ -use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; @@ -61,7 +60,11 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config */ public function get(string $path) { - $value = ArrayUtility::getValueByPath($this->settings, $path, '.'); + try { + $value = ArrayUtility::getValueByPath($this->settings, $path, '.'); + } catch (\Exception $e) { + $value = null; + } if ($value === null) { throw new InvalidArgumentException( diff --git a/Classes/Connection/Elasticsearch/Connection.php b/Classes/Connection/Elasticsearch/Connection.php index a1ea999f..a5e7d0f7 100644 --- a/Classes/Connection/Elasticsearch/Connection.php +++ b/Classes/Connection/Elasticsearch/Connection.php @@ -54,8 +54,8 @@ public function __construct( if ($elasticaClient === null) { $elasticaClient = new \Elastica\Client([ - 'host' => $this->configuration->getIfExists('connections.elasticsearch.host'), - 'port' => $this->configuration->getIfExists('connections.elasticsearch.port'), + 'host' => $this->configuration->get('connections.elasticsearch.host'), + 'port' => $this->configuration->get('connections.elasticsearch.port'), // TODO: Make configurable // 'log' => 'file', ]); diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index a6a89466..ce2335cc 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -127,55 +127,28 @@ protected function getRecordGenerator(): \Generator } } - /** - * @param array $record - * - * @throws \Exception - */ protected function prepareRecord(array &$record) { try { - $indexingConfiguration = $this->configuration->getIfExists( - 'indexing.' . $this->identifier . '.dataProcessing' - ); - - if (!empty($indexingConfiguration) && is_array($indexingConfiguration)) { - foreach ($indexingConfiguration as $configuration) { - $record = $this->dataProcessorService->executeDataProcessor( - $configuration, - $record, - $this->identifier - ); - } - } - } catch (\Exception $e) { - if ($e instanceof InvalidArgumentException) { - // Nothing to do - } elseif ($e instanceof MissingArrayPathException) { - // Nothing to do - } else { - throw $e; + foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) { + $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier); } + } catch (InvalidArgumentException $e) { + // Nothing to do } $this->handleAbstract($record); } - /** - * @param array $record - * - * @throws \Exception - */ protected function handleAbstract(array &$record) { $record['search_abstract'] = ''; try { - $indexConfiguration = $this->configuration->getIfExists( - 'indexing.' . $this->identifier . '.abstractFields' + $fieldsToUse = GeneralUtility::trimExplode( + ',', + $this->configuration->get('indexing.' . $this->identifier . '.abstractFields') ); - - $fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration); if ($fieldsToUse === []) { return; } @@ -185,14 +158,8 @@ protected function handleAbstract(array &$record) break; } } - } catch (\Exception $e) { - if ($e instanceof InvalidArgumentException) { - return; - } elseif ($e instanceof MissingArrayPathException) { - return; - } else { - throw $e; - } + } catch (InvalidArgumentException $e) { + return; } } diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index c7308542..668111d9 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -25,7 +25,6 @@ use Codappix\SearchCore\Domain\Index\IndexerInterface; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; use TYPO3\CMS\Core\SingletonInterface as Singleton; -use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; /** @@ -66,10 +65,6 @@ public function getIndexer(string $identifier) : IndexerInterface // Nothing to do, we throw exception below } catch (InvalidArgumentException $e) { // Nothing to do, we throw exception below - } catch (MissingArrayPathException $e) { - // Nothing to do, we throw exception below - } catch (\RuntimeException $exception) { - // Nothing to do, we throw exception below } throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442); From 274844dbba3c1ef986337163139c12e8d74e76b2 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:13:48 +0200 Subject: [PATCH 20/36] Do not introduce typo3 db legacy dependency Instead return expected object type. --- .../Domain/Index/TcaIndexer/TcaTableServiceTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php index 01345e4e..8106f6f1 100644 --- a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php +++ b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php @@ -25,7 +25,7 @@ use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService76; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService; use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; -use TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection; +use TYPO3\CMS\Core\Database\ConnectionPool; class TcaTableServiceTest extends AbstractUnitTestCase { @@ -40,16 +40,16 @@ class TcaTableServiceTest extends AbstractUnitTestCase protected $configuration; /** - * @var DatabaseConnection + * @var ConnectionPool */ - protected $databaseConnection; + protected $connectionPool; public function setUp() { parent::setUp(); $this->configuration = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock(); - $this->databaseConnection = $this->getMockBuilder(DatabaseConnection::class)->getMock(); + $this->connectionPool = $this->getMockBuilder(ConnectionPool::class)->getMock(); $className = TcaTableService::class; if ($this->isLegacyVersion()) { @@ -61,7 +61,7 @@ public function setUp() ->getMock(); $this->subject->expects($this->any()) ->method('getConnection') - ->willReturn($this->databaseConnection); + ->willReturn($this->connectionPool); $this->inject($this->subject, 'configuration', $this->configuration); $this->inject($this->subject, 'logger', $this->getMockedLogger()); From 7270ae0035c64550e40beb0949b4eccbf3f922e8 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:14:07 +0200 Subject: [PATCH 21/36] Adjust TYPO3 constraints also in ext_emconf --- ext_emconf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_emconf.php b/ext_emconf.php index be010dcf..6057cf09 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,7 +7,7 @@ 'clearCacheOnLoad' => 1, 'constraints' => [ 'depends' => [ - 'typo3' => '7.6.0-9.5.99', + 'typo3' => '8.7.0-9.5.99', 'php' => '7.0.0-7.2.99' ], 'conflicts' => [], From 67c75ac3cfa886955554dc2cf6d1b7993ce3dce0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:19:11 +0200 Subject: [PATCH 22/36] Update required versions and CI Main goal is to allow Travis to run builds again. Beside that, we do no longer support TYPO3 CMS 7, but 8.7 and 9.5. --- .travis.yml | 11 +++-------- Makefile | 13 ++----------- Tests/InstallPatches/composer.json.patch | 14 -------------- composer.json | 15 +++++++++------ 4 files changed, 14 insertions(+), 39 deletions(-) delete mode 100644 Tests/InstallPatches/composer.json.patch diff --git a/.travis.yml b/.travis.yml index 54c26374..5bdda126 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,5 @@ sudo: true -addons: - apt: - packages: - - oracle-java8-set-default before_install: - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.0.deb && sudo dpkg -i --force-confnew elasticsearch-5.2.0.deb && sudo service elasticsearch restart - mysql -u root -e 'GRANT ALL ON `typo3_ci_ft%`.* TO travis@127.0.0.1;' @@ -11,9 +7,8 @@ before_install: language: php php: - - 7.0 - - 7.1 - 7.2 + - 7.3 env: global: @@ -26,8 +21,8 @@ env: - typo3DatabaseUsername="travis" - typo3DatabasePassword="" matrix: - - TYPO3_VERSION="~7.6" - - TYPO3_VERSION="~8.7" + - TYPO3_VERSION="^8.7" + - TYPO3_VERSION="^9.5" matrix: fast_finish: true diff --git a/Makefile b/Makefile index 21f6c315..29f08611 100644 --- a/Makefile +++ b/Makefile @@ -4,24 +4,15 @@ current_dir := $(dir $(mkfile_path)) TYPO3_WEB_DIR := $(current_dir).Build/web TYPO3_PATH_ROOT := $(current_dir).Build/web # Allow different versions on travis -TYPO3_VERSION ?= ~8.7 +TYPO3_VERSION ?= ^9.5 typo3DatabaseName ?= "searchcore_test" typo3DatabaseUsername ?= "dev" typo3DatabasePassword ?= "dev" typo3DatabaseHost ?= "127.0.0.1" -sourceOrDist=--prefer-dist -ifeq ($(TYPO3_VERSION),~7.6) - sourceOrDist=--prefer-source -endif - .PHONY: install install: clean - if [ $(TYPO3_VERSION) = ~7.6 ]; then \ - patch composer.json Tests/InstallPatches/composer.json.patch; \ - fi - - COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev $(sourceOrDist) typo3/cms="$(TYPO3_VERSION)" + COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev typo3/cms-core="$(TYPO3_VERSION)" git checkout composer.json cgl: diff --git a/Tests/InstallPatches/composer.json.patch b/Tests/InstallPatches/composer.json.patch deleted file mode 100644 index 6f11cdc7..00000000 --- a/Tests/InstallPatches/composer.json.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/composer.json b/composer.json -index 83e5f47..e9fa296 100644 ---- a/composer.json -+++ b/composer.json -@@ -21,8 +21,7 @@ - "ruflin/elastica": "~3.2" - }, - "require-dev": { -- "phpunit/phpunit": "~6.4.4", -- "typo3/testing-framework": "~1.1.5", -+ "phpunit/phpunit": "~5.7.0", - "squizlabs/php_codesniffer": "~3.1.1" - }, - "config": { diff --git a/composer.json b/composer.json index aeb55527..0cdc2726 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,17 @@ } }, "require": { - "php": ">=7.0.0", - "typo3/cms-core": ">= 8.7.0 < 10.0.0", - "ruflin/elastica": "~3.2" + "php": ">=7.2.0 <8", + "typo3/cms-core": "^8.7 || ^9.5", + "ruflin/elastica": "^3.2" + }, + "suggests": { + "typo3/cms-form": "To update indexed records via Formframework." }, "require-dev": { - "phpunit/phpunit": "~6.4.4", - "typo3/testing-framework": "~1.1.5", - "squizlabs/php_codesniffer": "~3.1.1" + "squizlabs/php_codesniffer": "^3.4", + "typo3/testing-framework": "^2.0 || ^4.12", + "typo3/cms-form": "^8.7 || ^9.5" }, "config": { "optimize-autoloader": true, From 4d976f6294ea08a31195fd8522c405d021735ce5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 10:42:27 +0200 Subject: [PATCH 23/36] Ignore TYPO3 CMS 9 var folder --- .gitignore | 5 +++-- Makefile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f6db3ceb..3403a5d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -composer.lock -.Build +/composer.lock +/.Build +/var/ diff --git a/Makefile b/Makefile index 29f08611..ab158a88 100644 --- a/Makefile +++ b/Makefile @@ -39,4 +39,4 @@ uploadCodeCoverageToScrutinizer: php ocular.phar code-coverage:upload --format=php-clover .Build/report/functional/clover/coverage clean: - rm -rf .Build composer.lock + rm -rf .Build/ var/ composer.lock From b88869ecaa5747dd0ccc013cbd5f0d0603b690f9 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 5 May 2019 12:00:40 +0200 Subject: [PATCH 24/36] !!!|Fix unit tests for CMS 9 + PHP 7.3 * Add some more checks to remove PHP warnings / notices. * Adjust code to match CMS 9 API / interfaces. * Do no longer use "query" but only searchTerm, as query is internal API. --- Classes/Connection/SearchRequestInterface.php | 12 +- Classes/DataProcessing/GeoPointProcessor.php | 3 + Classes/Domain/Model/Query.php | 198 ++++++++++++++++++ Classes/Domain/Model/SearchRequest.php | 161 ++++---------- Classes/Domain/Model/SearchResult.php | 2 - Classes/Domain/Search/QueryFactory.php | 20 +- Tests/Unit/AbstractUnitTestCase.php | 2 +- .../Unit/Controller/SearchControllerTest.php | 2 + .../TcaRelationResolvingProcessorTest.php | 11 + Tests/Unit/Domain/Model/SearchRequestTest.php | 57 +---- Tests/Unit/Domain/Search/QueryFactoryTest.php | 11 +- .../Unit/Domain/Search/SearchServiceTest.php | 3 +- 12 files changed, 292 insertions(+), 190 deletions(-) create mode 100644 Classes/Domain/Model/Query.php diff --git a/Classes/Connection/SearchRequestInterface.php b/Classes/Connection/SearchRequestInterface.php index a4004472..7249593b 100644 --- a/Classes/Connection/SearchRequestInterface.php +++ b/Classes/Connection/SearchRequestInterface.php @@ -23,9 +23,9 @@ use Codappix\SearchCore\Connection\ConnectionInterface; use Codappix\SearchCore\Connection\FacetRequestInterface; use Codappix\SearchCore\Domain\Search\SearchService; -use TYPO3\CMS\Extbase\Persistence\QueryInterface; +use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; -interface SearchRequestInterface extends QueryInterface +interface SearchRequestInterface extends QueryResultInterface { /** * Returns the actual string the user searched for. @@ -48,6 +48,14 @@ public function addFacet(FacetRequestInterface $facet); */ public function getFacets() : array; + public function setLimit(int $limit); + + public function setOffset(int $offset); + + public function getLimit() : int; + + public function getOffset() : int; + /** * Workaround for paginate widget support which will * use the request to build another search. diff --git a/Classes/DataProcessing/GeoPointProcessor.php b/Classes/DataProcessing/GeoPointProcessor.php index 971e2c47..8eb55f4c 100644 --- a/Classes/DataProcessing/GeoPointProcessor.php +++ b/Classes/DataProcessing/GeoPointProcessor.php @@ -41,6 +41,9 @@ public function processData(array $record, array $configuration) : array protected function isApplyable(array $record, array $configuration) : bool { + if (!isset($configuration['lat']) || !isset($configuration['lon'])) { + return false; + } if (!isset($record[$configuration['lat']]) || !is_numeric($record[$configuration['lat']]) || trim($record[$configuration['lat']]) === '' diff --git a/Classes/Domain/Model/Query.php b/Classes/Domain/Model/Query.php new file mode 100644 index 00000000..ab948061 --- /dev/null +++ b/Classes/Domain/Model/Query.php @@ -0,0 +1,198 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use TYPO3\CMS\Extbase\Persistence\QueryInterface; + +/** + * Extbase QueryInterface + * Current implementation covers only paginate widget support. + */ +class Query implements QueryInterface +{ + /** + * @var int + */ + private $offset = 0; + + /** + * @var int + */ + private $limit = 10; + + public function execute($returnRawQueryResult = false) + { + if (! ($this->connection instanceof ConnectionInterface)) { + throw new \InvalidArgumentException( + 'Connection was not set before, therefore execute can not work. Use `setConnection` before.', + 1502197732 + ); + } + if (! ($this->searchService instanceof SearchService)) { + throw new \InvalidArgumentException( + 'SearchService was not set before, therefore execute can not work. Use `setSearchService` before.', + 1520325175 + ); + } + + return $this->searchService->processResult($this->connection->search($this)); + } + + public function setLimit($limit) + { + $this->limit = (int) $limit; + + return $this; + } + + public function setOffset($offset) + { + $this->offset = (int) $offset; + + return $this; + } + + public function getLimit() + { + return $this->limit; + } + + public function getOffset() + { + return $this->offset; + } + + public function getSource() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196146); + } + + public function setOrderings(array $orderings) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196163); + } + + public function matching($constraint) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196197); + } + + public function logicalAnd($constraint1) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); + } + + public function logicalOr($constraint1) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196198); + } + + public function logicalNot(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); + } + + public function equals($propertyName, $operand, $caseSensitive = true) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); + } + + public function like($propertyName, $operand, $caseSensitive = true) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); + } + + public function contains($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196200); + } + + public function in($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196167); + } + + public function lessThan($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196201); + } + + public function lessThanOrEqual($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); + } + + public function greaterThan($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196202); + } + + public function greaterThanOrEqual($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); + } + + public function getType() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196203); + } + + public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); + } + + public function getQuerySettings() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196205); + } + + public function count() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196169); + } + + public function getOrderings() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196206); + } + + public function getConstraint() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196171); + } + + public function isEmpty($propertyName) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196207); + } + + public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196172); + } + + public function getStatement() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); + } +} diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php index 2fb63306..d5cdf420 100644 --- a/Classes/Domain/Model/SearchRequest.php +++ b/Classes/Domain/Model/SearchRequest.php @@ -23,7 +23,9 @@ use Codappix\SearchCore\Connection\ConnectionInterface; use Codappix\SearchCore\Connection\FacetRequestInterface; use Codappix\SearchCore\Connection\SearchRequestInterface; +use Codappix\SearchCore\Domain\Model\Query; use Codappix\SearchCore\Domain\Search\SearchService; +use TYPO3\CMS\Extbase\Persistence\QueryInterface; /** * Represents a search request used to process an actual search. @@ -35,7 +37,7 @@ class SearchRequest implements SearchRequestInterface * * @var string */ - protected $query = ''; + protected $queryString = ''; /** * @var array @@ -48,14 +50,9 @@ class SearchRequest implements SearchRequestInterface protected $facets = []; /** - * @var int + * @var Query */ - protected $offset = 0; - - /** - * @var int - */ - protected $limit = 10; + private $query; /** * Used for QueryInterface implementation to allow execute method to work. @@ -72,19 +69,15 @@ class SearchRequest implements SearchRequestInterface /** * @param string $query */ - public function __construct(string $query = '') + public function __construct(string $queryString = '') { - $this->query = $query; - } - - public function getQuery() : string - { - return $this->query; + $this->queryString = $queryString; + $this->query = new Query(); } public function getSearchTerm() : string { - return $this->query; + return $this->queryString; } /** @@ -94,7 +87,8 @@ public function setFilter(array $filter) { $filter = \TYPO3\CMS\Core\Utility\ArrayUtility::removeArrayEntryByValue($filter, ''); $this->filter = \TYPO3\CMS\Core\Utility\ArrayUtility::filterRecursive($filter, function ($value) { - return !empty($value); + return (!is_array($value) && trim($value) !== '') + || is_array($value) && count($value) !== 0; }); } @@ -138,157 +132,94 @@ public function setSearchService(SearchService $searchService) $this->searchService = $searchService; } - // Extbase QueryInterface - // Current implementation covers only paginate widget support. - public function execute($returnRawQueryResult = false) - { - if (! ($this->connection instanceof ConnectionInterface)) { - throw new \InvalidArgumentException( - 'Connection was not set before, therefore execute can not work. Use `setConnection` before.', - 1502197732 - ); - } - if (! ($this->searchService instanceof SearchService)) { - throw new \InvalidArgumentException( - 'SearchService was not set before, therefore execute can not work. Use `setSearchService` before.', - 1520325175 - ); - } - - return $this->searchService->processResult($this->connection->search($this)); - } - - public function setLimit($limit) + public function setLimit(int $limit) { - $this->limit = (int) $limit; + $this->query->setLimit($limit); return $this; } - public function setOffset($offset) + public function setOffset(int $offset) { - $this->offset = (int) $offset; + $this->query->setOffset($offset); return $this; } - public function getLimit() - { - return $this->limit; - } - - public function getOffset() - { - return $this->offset; - } - - public function getSource() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196146); - } - - public function setOrderings(array $orderings) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196163); - } - - public function matching($constraint) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196197); - } - - public function logicalAnd($constraint1) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); - } - - public function logicalOr($constraint1) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196198); - } - - public function logicalNot(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); - } - - public function equals($propertyName, $operand, $caseSensitive = true) + public function getLimit() : int { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); + return $this->query->getLimit(); } - public function contains($propertyName, $operand) + public function getOffset() : int { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196200); + return $this->query->getOffset(); } - public function in($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196167); - } + // Implementation of QueryResultInterface - public function lessThan($propertyName, $operand) + public function getQuery(): QueryInterface { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196201); + return $this->query; } - public function lessThanOrEqual($propertyName, $operand) + /** + * Returns the first object in the result set + * + * @return object + */ + public function getFirst() { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); } - public function greaterThan($propertyName, $operand) + /** + * Returns an array with the objects in the result set + * + * @return array + */ + public function toArray() { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196202); } - public function greaterThanOrEqual($propertyName, $operand) + public function count(): int { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); } - public function getType() + public function current(): mixed { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196203); } - public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings) + public function key() { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); } - public function getQuerySettings() + public function next(): void { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196205); } - public function count() + public function rewind(): void { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196169); } - public function getOrderings() + public function valid(): bool { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196206); } - public function getConstraint() + public function offsetExists($offset): bool { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196171); + // TODO: Implement + return false; } - public function isEmpty($propertyName) + public function offsetGet($offset): mixed { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196207); } - public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source) + public function offsetSet($offset, $value) : void { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196172); } - public function getStatement() + public function offsetUnset($offset): void { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); } } diff --git a/Classes/Domain/Model/SearchResult.php b/Classes/Domain/Model/SearchResult.php index 516c333e..60e9c506 100644 --- a/Classes/Domain/Model/SearchResult.php +++ b/Classes/Domain/Model/SearchResult.php @@ -103,8 +103,6 @@ public function current() public function next() { ++$this->position; - - return $this->current(); } public function key() diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php index a2f6c43f..bde8b696 100644 --- a/Classes/Domain/Search/QueryFactory.php +++ b/Classes/Domain/Search/QueryFactory.php @@ -85,7 +85,7 @@ protected function createElasticaQuery(SearchRequestInterface $searchRequest) : protected function addSize(SearchRequestInterface $searchRequest, array &$query) { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + ArrayUtility::mergeRecursiveWithOverrule($query, [ 'from' => $searchRequest->getOffset(), 'size' => $searchRequest->getLimit(), ]); @@ -108,7 +108,7 @@ protected function addSearch(SearchRequestInterface $searchRequest, array &$quer $matchExpression['minimum_should_match'] = $minimumShouldMatch; } - $query = ArrayUtility::setValueByPath($query, 'query.bool.must.0.multi_match', $matchExpression); + $query = ArrayUtility::setValueByPath($query, 'query.bool.must.0.multi_match', $matchExpression, '.'); } protected function addBoosts(SearchRequestInterface $searchRequest, array &$query) @@ -137,7 +137,7 @@ protected function addBoosts(SearchRequestInterface $searchRequest, array &$quer } if (!empty($boostQueryParts)) { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + ArrayUtility::mergeRecursiveWithOverrule($query, [ 'query' => [ 'bool' => [ 'should' => $boostQueryParts, @@ -149,6 +149,10 @@ protected function addBoosts(SearchRequestInterface $searchRequest, array &$quer protected function addFactorBoost(array &$query) { + if (!isset($query['query'])) { + return; + } + try { $query['query'] = [ 'function_score' => [ @@ -164,7 +168,7 @@ protected function addFactorBoost(array &$query) protected function addFields(SearchRequestInterface $searchRequest, array &$query) { try { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + ArrayUtility::mergeRecursiveWithOverrule($query, [ 'stored_fields' => GeneralUtility::trimExplode( ',', $this->configuration->get('searching.fields.stored_fields'), @@ -183,7 +187,7 @@ protected function addFields(SearchRequestInterface $searchRequest, array &$quer ); $scriptFields = $this->configurationUtility->filterByCondition($scriptFields); if ($scriptFields !== []) { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, ['script_fields' => $scriptFields]); + ArrayUtility::mergeRecursiveWithOverrule($query, ['script_fields' => $scriptFields]); } } catch (InvalidArgumentException $e) { // Nothing configured @@ -196,7 +200,7 @@ protected function addSort(SearchRequestInterface $searchRequest, array &$query) $sorting = $this->configurationUtility->replaceArrayValuesWithRequestContent($searchRequest, $sorting); $sorting = $this->configurationUtility->filterByCondition($sorting); if ($sorting !== []) { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, ['sort' => $sorting]); + ArrayUtility::mergeRecursiveWithOverrule($query, ['sort' => $sorting]); } } @@ -215,7 +219,7 @@ protected function addFilter(SearchRequestInterface $searchRequest, array &$quer ); } - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + ArrayUtility::mergeRecursiveWithOverrule($query, [ 'query' => [ 'bool' => [ 'filter' => $filter, @@ -260,7 +264,7 @@ protected function buildFilter(string $name, $value, array $config) : array protected function addFacets(SearchRequestInterface $searchRequest, array &$query) { foreach ($searchRequest->getFacets() as $facet) { - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + ArrayUtility::mergeRecursiveWithOverrule($query, [ 'aggs' => [ $facet->getIdentifier() => $facet->getConfig(), ], diff --git a/Tests/Unit/AbstractUnitTestCase.php b/Tests/Unit/AbstractUnitTestCase.php index 384236c5..ea90bd6b 100644 --- a/Tests/Unit/AbstractUnitTestCase.php +++ b/Tests/Unit/AbstractUnitTestCase.php @@ -20,10 +20,10 @@ * 02110-1301, USA. */ -use TYPO3\CMS\Core\Tests\UnitTestCase as CoreTestCase; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Form\Service\TranslationService; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase as CoreTestCase; abstract class AbstractUnitTestCase extends CoreTestCase { diff --git a/Tests/Unit/Controller/SearchControllerTest.php b/Tests/Unit/Controller/SearchControllerTest.php index 67c6d98f..5ed5781f 100644 --- a/Tests/Unit/Controller/SearchControllerTest.php +++ b/Tests/Unit/Controller/SearchControllerTest.php @@ -29,6 +29,8 @@ class SearchControllerTest extends AbstractUnitTestCase { + protected $resetSingletonInstances = true; + /** * @var SearchController */ diff --git a/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php b/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php index e7abb077..6f9fd00f 100644 --- a/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php +++ b/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php @@ -23,6 +23,7 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor; use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Extbase\Object\ObjectManager; use \TYPO3\CMS\Core\Utility\GeneralUtility; @@ -51,6 +52,14 @@ public function setUp() $this->subject = GeneralUtility::makeInstance(ObjectManager::class) ->get(TcaRelationResolvingProcessor::class); + + $GLOBALS['LANG'] = $this->getMockBuilder(LanguageService::class)->getMock(); + } + + public function tearDown() + { + unset($GLOBALS['LANG']); + parent::tearDown(); } /** @@ -118,6 +127,7 @@ public function sysLanguageUidZeroIsKept() public function renderTypeInputDateTimeIsHandled() { $originalRecord = [ + 'uid' => 10, 'endtime' => 99999999999, 'starttime' => 1523010960, ]; @@ -159,6 +169,7 @@ public function renderTypeInputDateTimeIsHandled() $record = $this->subject->processData($originalRecord, $configuration); $this->assertSame( [ + 'uid' => '10', 'endtime' => '16-11-38 09:46', 'starttime' => 1523010960, ], diff --git a/Tests/Unit/Domain/Model/SearchRequestTest.php b/Tests/Unit/Domain/Model/SearchRequestTest.php index 28f90e3c..da7c3547 100644 --- a/Tests/Unit/Domain/Model/SearchRequestTest.php +++ b/Tests/Unit/Domain/Model/SearchRequestTest.php @@ -58,7 +58,8 @@ public function possibleEmptyFilter() 'Single filter with empty recursive values' => [ 'filter' => [ 'someFilter' => [ - 'someKey' => '', + 'firstEmptyKey' => '', + 'secondEmptyKey' => '', ], ], ], @@ -80,58 +81,4 @@ public function filterIsSet() 'Filter was not set.' ); } - - /** - * @test - */ - public function exceptionIsThrownIfSearchServiceWasNotSet() - { - $subject = new SearchRequest(); - $subject->setConnection($this->getMockBuilder(ConnectionInterface::class)->getMock()); - $this->expectException(\InvalidArgumentException::class); - $subject->execute(); - } - - /** - * @test - */ - public function exceptionIsThrownIfConnectionWasNotSet() - { - $subject = new SearchRequest(); - $subject->setSearchService( - $this->getMockBuilder(SearchService::class) - ->disableOriginalConstructor() - ->getMock() - ); - $this->expectException(\InvalidArgumentException::class); - $subject->execute(); - } - - /** - * @test - */ - public function executionMakesUseOfProvidedConnectionAndSearchService() - { - $searchServiceMock = $this->getMockBuilder(SearchService::class) - ->disableOriginalConstructor() - ->getMock(); - $connectionMock = $this->getMockBuilder(ConnectionInterface::class) - ->getMock(); - $searchResultMock = $this->getMockBuilder(SearchResultInterface::class) - ->getMock(); - - $subject = new SearchRequest(); - $subject->setSearchService($searchServiceMock); - $subject->setConnection($connectionMock); - - $connectionMock->expects($this->once()) - ->method('search') - ->with($subject) - ->willReturn($searchResultMock); - $searchServiceMock->expects($this->once()) - ->method('processResult') - ->with($searchResultMock); - - $subject->execute(); - } } diff --git a/Tests/Unit/Domain/Search/QueryFactoryTest.php b/Tests/Unit/Domain/Search/QueryFactoryTest.php index dc824c5f..65bad8d2 100644 --- a/Tests/Unit/Domain/Search/QueryFactoryTest.php +++ b/Tests/Unit/Domain/Search/QueryFactoryTest.php @@ -156,9 +156,8 @@ public function emptyFilterIsNotAddedToQuery() ); $query = $this->subject->create($searchRequest); - $this->assertSame( - null, - $query->toArray()['query']['bool']['filter'], + $this->assertTrue( + !isset($query->toArray()['query']['bool']['filter']), 'Filter was added to query, even if no filter exists.' ); } @@ -405,7 +404,7 @@ public function emptySearchStringWillNotAddSearchToQuery() $query = $this->subject->create($searchRequest); $this->assertInstanceOf( - stdClass, + \stdClass::class, $query->toArray()['query']['match_all'], 'Empty search request does not create expected query.' ); @@ -543,7 +542,7 @@ public function scriptFieldsAreAddedToQuery() 'config' => 'something', ], 'field2' => [ - 'config' => '{request.query}', + 'config' => '{request.searchTerm}', ], ], $this->throwException(new InvalidArgumentException) @@ -613,7 +612,7 @@ public function sortIsAddedToQuery() 'config' => 'something', ], 'field2' => [ - 'config' => '{request.query}', + 'config' => '{request.searchTerm}', ], ] )); diff --git a/Tests/Unit/Domain/Search/SearchServiceTest.php b/Tests/Unit/Domain/Search/SearchServiceTest.php index 3b880768..b7f6b88d 100644 --- a/Tests/Unit/Domain/Search/SearchServiceTest.php +++ b/Tests/Unit/Domain/Search/SearchServiceTest.php @@ -23,6 +23,7 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\ConnectionInterface; +use Codappix\SearchCore\Connection\SearchRequestInterface; use Codappix\SearchCore\Connection\SearchResultInterface; use Codappix\SearchCore\DataProcessing\Service as DataProcessorService; use Codappix\SearchCore\Domain\Model\SearchRequest; @@ -182,7 +183,7 @@ public function configuredFilterWithValueZeroAreAddedToRequestWithoutAnyFilter() $this->connection->expects($this->once()) ->method('search') - ->with($this->callback(function ($searchRequest) { + ->with($this->callback(function (SearchRequestInterface $searchRequest) { return $searchRequest->getFilter() === ['property' => '0']; })) ->willReturn($this->getMockBuilder(SearchResultInterface::class)->getMock()); From c2f01b3c32badb0a90b78717406d7d1653698040 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 16:36:12 +0200 Subject: [PATCH 25/36] Remove unnecessary output during make commands --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ab158a88..360db77c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ typo3DatabaseHost ?= "127.0.0.1" .PHONY: install install: clean - COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev typo3/cms-core="$(TYPO3_VERSION)" + COMPOSER_PROCESS_TIMEOUT=1000 composer require --dev typo3/cms-core="$(TYPO3_VERSION)" git checkout composer.json cgl: @@ -24,12 +24,12 @@ functionalTests: typo3DatabasePassword=$(typo3DatabasePassword) \ typo3DatabaseHost=$(typo3DatabaseHost) \ TYPO3_PATH_WEB=$(TYPO3_WEB_DIR) \ - .Build/bin/phpunit --colors --debug -v \ + .Build/bin/phpunit --colors -v \ -c Tests/Functional/FunctionalTests.xml unitTests: TYPO3_PATH_WEB=$(TYPO3_WEB_DIR) \ - .Build/bin/phpunit --colors --debug -v \ + .Build/bin/phpunit --colors -v \ -c Tests/Unit/UnitTests.xml uploadCodeCoverage: uploadCodeCoverageToScrutinizer From 373505b9d42128752a12a084fa03aeb1b87f3ba4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 16:46:52 +0200 Subject: [PATCH 26/36] Extend new FunctionalTestCase provided by testing framework --- Tests/Functional/AbstractFunctionalTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/AbstractFunctionalTestCase.php b/Tests/Functional/AbstractFunctionalTestCase.php index d0154576..fde97617 100644 --- a/Tests/Functional/AbstractFunctionalTestCase.php +++ b/Tests/Functional/AbstractFunctionalTestCase.php @@ -20,7 +20,7 @@ * 02110-1301, USA. */ -use TYPO3\CMS\Core\Tests\FunctionalTestCase as CoreTestCase; +use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as CoreTestCase; /** * All functional tests should extend this base class. From c4e28211afb45ee09ebb7d566f4ed4005f3ddaa5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 16:47:17 +0200 Subject: [PATCH 27/36] Adjust dataset paths for import --- Tests/Functional/AbstractFunctionalTestCase.php | 2 +- .../Connection/Elasticsearch/IndexTcaTableTest.php | 4 ++-- .../DataProcessing/TcaRelationResolvingProcessorTest.php | 8 ++++---- Tests/Functional/Indexing/PagesIndexerTest.php | 4 ++-- Tests/Functional/Indexing/TcaIndexerTest.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tests/Functional/AbstractFunctionalTestCase.php b/Tests/Functional/AbstractFunctionalTestCase.php index fde97617..f0b18715 100644 --- a/Tests/Functional/AbstractFunctionalTestCase.php +++ b/Tests/Functional/AbstractFunctionalTestCase.php @@ -37,7 +37,7 @@ public function setUp() \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject(); foreach ($this->getDataSets() as $dataSet) { - $this->importDataSet($dataSet); + $this->importDataSet('EXT:search_core/' . $dataSet); } $this->setUpFrontendRootPage(1, $this->getTypoScriptFilesForFrontendRootPage()); diff --git a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php index ae671dda..40b5fa43 100644 --- a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php +++ b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php @@ -124,7 +124,7 @@ public function indexingRespectsUserWhereClause() parent::getTypoScriptFilesForFrontendRootPage(), ['EXT:search_core/Tests/Functional/Fixtures/Indexing/UserWhereClause.ts'] )); - $this->importDataSet('Tests/Functional/Fixtures/Indexing/UserWhereClause.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/UserWhereClause.xml'); \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class) ->get(IndexerFactory::class) @@ -157,7 +157,7 @@ public function indexingRespectsUserWhereClause() */ public function resolvesRelations() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/ResolveRelations.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/ResolveRelations.xml'); \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class) ->get(IndexerFactory::class) diff --git a/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php index c5011df9..28f2854e 100644 --- a/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php +++ b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php @@ -33,7 +33,7 @@ class TcaRelationResolvingProcessorTest extends AbstractFunctionalTestCase */ public function resolveInlineRelation() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/InlineRelation.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/InlineRelation.xml'); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'sys_file'; @@ -55,7 +55,7 @@ public function resolveInlineRelation() */ public function resolveStaticSelectItems() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/StaticSelectItems.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/StaticSelectItems.xml'); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; @@ -74,7 +74,7 @@ public function resolveStaticSelectItems() */ public function resolveForeignDb() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignDb.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignDb.xml'); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; @@ -96,7 +96,7 @@ public function resolveForeignDb() */ public function resolveForeignMmSelect() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignMmSelect.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignMmSelect.xml'); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; diff --git a/Tests/Functional/Indexing/PagesIndexerTest.php b/Tests/Functional/Indexing/PagesIndexerTest.php index acc8b68d..69db4cf5 100644 --- a/Tests/Functional/Indexing/PagesIndexerTest.php +++ b/Tests/Functional/Indexing/PagesIndexerTest.php @@ -33,7 +33,7 @@ class PagesIndexerTest extends AbstractFunctionalTestCase */ public function pagesContainAllAdditionalInformation() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml'); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class); $tableName = 'pages'; @@ -71,7 +71,7 @@ public function pagesContainAllAdditionalInformation() */ public function rootLineIsRespectedDuringIndexing($dataSetPath) { - $this->importDataSet($dataSetPath); + $this->importDataSet('EXT:search_core/' . $dataSetPath); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class); $tableName = 'pages'; diff --git a/Tests/Functional/Indexing/TcaIndexerTest.php b/Tests/Functional/Indexing/TcaIndexerTest.php index 472cc154..b447c994 100644 --- a/Tests/Functional/Indexing/TcaIndexerTest.php +++ b/Tests/Functional/Indexing/TcaIndexerTest.php @@ -43,7 +43,7 @@ protected function getTypoScriptFilesForFrontendRootPage() */ public function respectRootLineBlacklist() { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.xml'); + $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.xml'); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class); $tableName = 'tt_content'; $tableService = $objectManager->get( From 6cfca1f259230b987607709c18ad3b25b12b31ca Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:05:15 +0200 Subject: [PATCH 28/36] Respect cycler pages during indexing This was done by TYPO3 itself before Version 9. Since version 9, we have to take care ourselves. --- Classes/Domain/Index/TcaIndexer/TcaTableService.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index 1330e228..4c029a9d 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\RootlineUtility; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; +use TYPO3\CMS\Frontend\Page\PageRepository; /** * Encapsulate logik related to TCA configuration. @@ -324,6 +325,18 @@ protected function isRecordBlacklistedByRootline(array &$record) : bool return true; } + if ($pageInRootLine['doktype'] === PageRepository::DOKTYPE_RECYCLER) { + $this->logger->info( + sprintf( + 'Record %u is black listed due to being within recycler page %u.', + $record['uid'], + $pageInRootLine['uid'] + ), + [$record, $pageInRootLine] + ); + return true; + } + if ($pageInRootLine['extendToSubpages'] && ( ($pageInRootLine['endtime'] > 0 && $pageInRootLine['endtime'] <= time()) || ($pageInRootLine['starttime'] > 0 && $pageInRootLine['starttime'] >= time()) From 95e867488bcd23cc67345c33dfd099772211d3fd Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:12:41 +0200 Subject: [PATCH 29/36] Remove supported TYPO3 version lower 9.5 --- .travis.yml | 1 - composer.json | 7 +++---- ext_emconf.php | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bdda126..bf0024e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ env: - typo3DatabaseUsername="travis" - typo3DatabasePassword="" matrix: - - TYPO3_VERSION="^8.7" - TYPO3_VERSION="^9.5" matrix: diff --git a/composer.json b/composer.json index 0cdc2726..6de2fadb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=7.2.0 <8", - "typo3/cms-core": "^8.7 || ^9.5", + "typo3/cms-core": "^9.5", "ruflin/elastica": "^3.2" }, "suggests": { @@ -25,11 +25,10 @@ }, "require-dev": { "squizlabs/php_codesniffer": "^3.4", - "typo3/testing-framework": "^2.0 || ^4.12", - "typo3/cms-form": "^8.7 || ^9.5" + "typo3/testing-framework": "^4.12", + "typo3/cms-form": "^9.5" }, "config": { - "optimize-autoloader": true, "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin" }, diff --git a/ext_emconf.php b/ext_emconf.php index 6057cf09..069929de 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,8 +7,8 @@ 'clearCacheOnLoad' => 1, 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-9.5.99', - 'php' => '7.0.0-7.2.99' + 'typo3' => '9.5.7-9.5.99', + 'php' => '7.2.0-7.3.99' ], 'conflicts' => [], ], @@ -17,8 +17,8 @@ 'Codappix\\SearchCore\\' => 'Classes', ], ], - 'state' => 'beta', - 'version' => '0.0.7', + 'state' => 'stable', + 'version' => '1.0.0', 'author' => 'Daniel Siepmann', 'author_email' => 'coding@daniel-siepmann.de', ]; From ff6e7211589ac4ef8dd389a8ec2d8e0c4e6df552 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:14:35 +0200 Subject: [PATCH 30/36] Shorten long lines within tests to follow CGL --- .../TcaRelationResolvingProcessorTest.php | 16 ++++++++++++---- Tests/Functional/Indexing/TcaIndexerTest.php | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php index 28f2854e..942795ff 100644 --- a/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php +++ b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php @@ -33,7 +33,9 @@ class TcaRelationResolvingProcessorTest extends AbstractFunctionalTestCase */ public function resolveInlineRelation() { - $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/InlineRelation.xml'); + $this->importDataSet( + 'EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/InlineRelation.xml' + ); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'sys_file'; @@ -55,7 +57,9 @@ public function resolveInlineRelation() */ public function resolveStaticSelectItems() { - $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/StaticSelectItems.xml'); + $this->importDataSet( + 'EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/StaticSelectItems.xml' + ); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; @@ -74,7 +78,9 @@ public function resolveStaticSelectItems() */ public function resolveForeignDb() { - $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignDb.xml'); + $this->importDataSet( + 'EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignDb.xml' + ); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; @@ -96,7 +102,9 @@ public function resolveForeignDb() */ public function resolveForeignMmSelect() { - $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignMmSelect.xml'); + $this->importDataSet( + 'EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RelationResolver/ForeignMmSelect.xml' + ); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; diff --git a/Tests/Functional/Indexing/TcaIndexerTest.php b/Tests/Functional/Indexing/TcaIndexerTest.php index b447c994..30059033 100644 --- a/Tests/Functional/Indexing/TcaIndexerTest.php +++ b/Tests/Functional/Indexing/TcaIndexerTest.php @@ -43,7 +43,9 @@ protected function getTypoScriptFilesForFrontendRootPage() */ public function respectRootLineBlacklist() { - $this->importDataSet('EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.xml'); + $this->importDataSet( + 'EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.xml' + ); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class); $tableName = 'tt_content'; $tableService = $objectManager->get( From 9946276f43f447631a5a5e9445633360690b26ac Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:27:55 +0200 Subject: [PATCH 31/36] Remove compatibility layer, as only V9 is supported --- Classes/Bootstrap.php | 27 -------- .../Compatibility/ExtensionConfiguration.php | 26 -------- .../ExtensionConfigurationInterface.php | 7 --- .../ImplementationRegistrationService.php | 62 ------------------- Classes/Compatibility/TypoScriptService.php | 31 ---------- .../TypoScriptServiceInterface.php | 30 --------- .../Version87/ExtensionConfiguration.php | 13 ---- ...entObjectDataProcessorAdapterProcessor.php | 6 +- ...bjectDataProcessorAdapterProcessorTest.php | 11 +--- ext_localconf.php | 8 +-- 10 files changed, 8 insertions(+), 213 deletions(-) delete mode 100644 Classes/Bootstrap.php delete mode 100644 Classes/Compatibility/ExtensionConfiguration.php delete mode 100644 Classes/Compatibility/ExtensionConfigurationInterface.php delete mode 100644 Classes/Compatibility/ImplementationRegistrationService.php delete mode 100644 Classes/Compatibility/TypoScriptService.php delete mode 100644 Classes/Compatibility/TypoScriptServiceInterface.php delete mode 100644 Classes/Compatibility/Version87/ExtensionConfiguration.php diff --git a/Classes/Bootstrap.php b/Classes/Bootstrap.php deleted file mode 100644 index 0cd8a890..00000000 --- a/Classes/Bootstrap.php +++ /dev/null @@ -1,27 +0,0 @@ -get( - ExtensionConfigurationInterface::class - ); - } -} diff --git a/Classes/Compatibility/ExtensionConfiguration.php b/Classes/Compatibility/ExtensionConfiguration.php deleted file mode 100644 index fb727750..00000000 --- a/Classes/Compatibility/ExtensionConfiguration.php +++ /dev/null @@ -1,26 +0,0 @@ -get(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class); - } - - /** - * @param $extensionKey - * @return mixed - * @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException - * @throws \TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException - */ - public function get($extensionKey) - { - return $this->base()->get($extensionKey); - } -} diff --git a/Classes/Compatibility/ExtensionConfigurationInterface.php b/Classes/Compatibility/ExtensionConfigurationInterface.php deleted file mode 100644 index f62ab2d3..00000000 --- a/Classes/Compatibility/ExtensionConfigurationInterface.php +++ /dev/null @@ -1,7 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService; -use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Extbase\Object\Container\Container; - -/** - * Register different concrete implementations, depending on current TYPO3 version. - * This way we can provide working implementations for multiple TYPO3 versions. - */ -class ImplementationRegistrationService -{ - public static function registerImplementations() - { - /** @var Container $container */ - $container = GeneralUtility::makeInstance(Container::class); - - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 9000000) { - $container->registerImplementation( - ExtensionConfigurationInterface::class, - ExtensionConfiguration::class - ); - } elseif (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $container->registerImplementation( - ExtensionConfigurationInterface::class, - Version87\ExtensionConfiguration::class - ); - } - - $container->registerImplementation( - TypoScriptServiceInterface::class, - TypoScriptService::class - ); - - $container->registerImplementation( - TcaTableServiceInterface::class, - TcaTableService::class - ); - } -} diff --git a/Classes/Compatibility/TypoScriptService.php b/Classes/Compatibility/TypoScriptService.php deleted file mode 100644 index e5aa7886..00000000 --- a/Classes/Compatibility/TypoScriptService.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use TYPO3\CMS\Core\TypoScript\TypoScriptService as CoreTypoScriptService; - -/** - * Used since TYPO3 CMS 8.7. - */ -class TypoScriptService extends CoreTypoScriptService implements TypoScriptServiceInterface -{ - -} diff --git a/Classes/Compatibility/TypoScriptServiceInterface.php b/Classes/Compatibility/TypoScriptServiceInterface.php deleted file mode 100644 index 8e6a9e46..00000000 --- a/Classes/Compatibility/TypoScriptServiceInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -/** - * Allows to use DI configuration to switch concrete implementation, depending - * on current TYPO3 Version. - */ -interface TypoScriptServiceInterface -{ - public function convertPlainArrayToTypoScriptArray(array $plainArray); -} diff --git a/Classes/Compatibility/Version87/ExtensionConfiguration.php b/Classes/Compatibility/Version87/ExtensionConfiguration.php deleted file mode 100644 index 6ff91afb..00000000 --- a/Classes/Compatibility/Version87/ExtensionConfiguration.php +++ /dev/null @@ -1,13 +0,0 @@ -typoScriptService = $typoScriptService; } diff --git a/Tests/Functional/DataProcessing/ContentObjectDataProcessorAdapterProcessorTest.php b/Tests/Functional/DataProcessing/ContentObjectDataProcessorAdapterProcessorTest.php index bb997cf5..0ebb3e55 100644 --- a/Tests/Functional/DataProcessing/ContentObjectDataProcessorAdapterProcessorTest.php +++ b/Tests/Functional/DataProcessing/ContentObjectDataProcessorAdapterProcessorTest.php @@ -20,8 +20,7 @@ * 02110-1301, USA. */ -use Codappix\SearchCore\Compatibility\TypoScriptService76; -use Codappix\SearchCore\Compatibility\TypoScriptService; +use TYPO3\CMS\Core\TypoScript\TypoScriptService; use Codappix\SearchCore\DataProcessing\ContentObjectDataProcessorAdapterProcessor; use Codappix\SearchCore\Tests\Functional\AbstractFunctionalTestCase; use TYPO3\CMS\Frontend\DataProcessing\SplitProcessor; @@ -45,13 +44,7 @@ public function contentObjectDataProcessorIsExecuted() 'new_content' => ['value1', 'value2'], ]; - if ($this->isLegacyVersion()) { - $typoScriptService = new TypoScriptService76(); - } else { - $typoScriptService = new TypoScriptService(); - } - - $subject = new ContentObjectDataProcessorAdapterProcessor($typoScriptService); + $subject = new ContentObjectDataProcessorAdapterProcessor(new TypoScriptService()); $processedData = $subject->processData($record, $configuration); $this->assertSame( $expectedData, diff --git a/ext_localconf.php b/ext_localconf.php index b492cd18..5a551f7d 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -40,11 +40,9 @@ function ($extensionKey) { ] ); - \Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations(); - - - // API does make use of object manager, therefore use GLOBALS - $extensionConfiguration = \Codappix\SearchCore\Bootstrap::getExtensionConfiguration()->get($extensionKey); + $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + \TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class + )->get($extensionKey); if ($extensionConfiguration === false || !isset($extensionConfiguration['disable']['elasticsearch']) From b04ed99c07d37c384bbdb56205fe89d0c0de802a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:51:58 +0200 Subject: [PATCH 32/36] TASK: Add changelog for V9 support and breaking changes --- Documentation/source/changelog.rst | 29 +++++++++++++------ .../1.0.0/20190517-typo3-v9-update.rst | 20 +++++++++++++ .../20180306-120-facet-configuration.rst | 0 .../20180308-131-respect-page-cache-clear.rst | 0 .../20180308-introduce-php70-type-hints.rst | 0 .../20180309-25-provide-sys-language-uid.rst | 0 ...15-134-make-conent-fields-configurable.rst | 0 .../20180410-148-keep-sys_language_uid.rst | 0 ...t-relation-resolver-to-data-processing.rst | 0 ...180518-75-make-index-name-configurable.rst | 0 ...-allow-zero-as-typoscript-filter-value.rst | 0 11 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst rename Documentation/source/changelog/{ => prior-1.0.0}/20180306-120-facet-configuration.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180308-131-respect-page-cache-clear.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180308-introduce-php70-type-hints.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180309-25-provide-sys-language-uid.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180315-134-make-conent-fields-configurable.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180410-148-keep-sys_language_uid.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180424-149-extract-relation-resolver-to-data-processing.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180518-75-make-index-name-configurable.rst (100%) rename Documentation/source/changelog/{ => prior-1.0.0}/20180926-163-allow-zero-as-typoscript-filter-value.rst (100%) diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst index 2cad89f0..84d5ab8e 100644 --- a/Documentation/source/changelog.rst +++ b/Documentation/source/changelog.rst @@ -1,16 +1,27 @@ Changelog ========= +v1.0.0 +------ + .. toctree:: :maxdepth: 1 :glob: - changelog/20180518-75-make-index-name-configurable - changelog/20180424-149-extract-relation-resolver-to-data-processing - changelog/20180410-148-keep-sys_language_uid - changelog/20180315-134-make-conent-fields-configurable - changelog/20180309-25-provide-sys-language-uid - changelog/20180308-131-respect-page-cache-clear - changelog/20180308-introduce-php70-type-hints - changelog/20180306-120-facet-configuration - changelog/20180926-163-allow-zero-as-typoscript-filter-value + changelog/1.0.0/* + +prior v1.0.0 +------------ + +.. toctree:: + :maxdepth: 1 + + changelog/prior-1.0.0/20180518-75-make-index-name-configurable + changelog/prior-1.0.0/20180424-149-extract-relation-resolver-to-data-processing + changelog/prior-1.0.0/20180410-148-keep-sys_language_uid + changelog/prior-1.0.0/20180315-134-make-conent-fields-configurable + changelog/prior-1.0.0/20180309-25-provide-sys-language-uid + changelog/prior-1.0.0/20180308-131-respect-page-cache-clear + changelog/prior-1.0.0/20180308-introduce-php70-type-hints + changelog/prior-1.0.0/20180306-120-facet-configuration + changelog/prior-1.0.0/20180926-163-allow-zero-as-typoscript-filter-value diff --git a/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst b/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst new file mode 100644 index 00000000..bbd1f477 --- /dev/null +++ b/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst @@ -0,0 +1,20 @@ +Breaking change "TYPO3 v9 LTS Update" +===================================== + +The extension does now officially support TYPO3 CMS v9.5 LTS. +This change contains some breaking changes: + +* Support for TYPO3 versions lower then 9.5 LTS has been dropped. + +* Due to dropped TYPO3 CMS < v9 support, also all PHP Code within ``Compatibility`` + namespace was removed. + +* Fluid variable ``{request.query}`` is no longer provided, due to internal API + changes. Use ``{request.searchTerm}`` instead. + +* PHP Interface ``\Codappix\SearchCore\Connection\SearchRequestInterface`` has + changed, due to extending TYPO3 Interface + ``\TYPO3\CMS\Extbase\Persistence\QueryResultInterface``. + + Therefore also PHP class ``\Codappix\SearchCore\Domain\Model\SearchRequest`` has + been adjusted. diff --git a/Documentation/source/changelog/20180306-120-facet-configuration.rst b/Documentation/source/changelog/prior-1.0.0/20180306-120-facet-configuration.rst similarity index 100% rename from Documentation/source/changelog/20180306-120-facet-configuration.rst rename to Documentation/source/changelog/prior-1.0.0/20180306-120-facet-configuration.rst diff --git a/Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst b/Documentation/source/changelog/prior-1.0.0/20180308-131-respect-page-cache-clear.rst similarity index 100% rename from Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst rename to Documentation/source/changelog/prior-1.0.0/20180308-131-respect-page-cache-clear.rst diff --git a/Documentation/source/changelog/20180308-introduce-php70-type-hints.rst b/Documentation/source/changelog/prior-1.0.0/20180308-introduce-php70-type-hints.rst similarity index 100% rename from Documentation/source/changelog/20180308-introduce-php70-type-hints.rst rename to Documentation/source/changelog/prior-1.0.0/20180308-introduce-php70-type-hints.rst diff --git a/Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst b/Documentation/source/changelog/prior-1.0.0/20180309-25-provide-sys-language-uid.rst similarity index 100% rename from Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst rename to Documentation/source/changelog/prior-1.0.0/20180309-25-provide-sys-language-uid.rst diff --git a/Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst b/Documentation/source/changelog/prior-1.0.0/20180315-134-make-conent-fields-configurable.rst similarity index 100% rename from Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst rename to Documentation/source/changelog/prior-1.0.0/20180315-134-make-conent-fields-configurable.rst diff --git a/Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst b/Documentation/source/changelog/prior-1.0.0/20180410-148-keep-sys_language_uid.rst similarity index 100% rename from Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst rename to Documentation/source/changelog/prior-1.0.0/20180410-148-keep-sys_language_uid.rst diff --git a/Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst b/Documentation/source/changelog/prior-1.0.0/20180424-149-extract-relation-resolver-to-data-processing.rst similarity index 100% rename from Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst rename to Documentation/source/changelog/prior-1.0.0/20180424-149-extract-relation-resolver-to-data-processing.rst diff --git a/Documentation/source/changelog/20180518-75-make-index-name-configurable.rst b/Documentation/source/changelog/prior-1.0.0/20180518-75-make-index-name-configurable.rst similarity index 100% rename from Documentation/source/changelog/20180518-75-make-index-name-configurable.rst rename to Documentation/source/changelog/prior-1.0.0/20180518-75-make-index-name-configurable.rst diff --git a/Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst b/Documentation/source/changelog/prior-1.0.0/20180926-163-allow-zero-as-typoscript-filter-value.rst similarity index 100% rename from Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst rename to Documentation/source/changelog/prior-1.0.0/20180926-163-allow-zero-as-typoscript-filter-value.rst From 1f082ab673abae012543d4394f791e5c47cbab6a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 17 May 2019 17:53:49 +0200 Subject: [PATCH 33/36] Do not change CGL Keep changed for pull request to a necessary minimum. --- Classes/Domain/Index/AbstractIndexer.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index ce2335cc..88b11972 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -98,7 +98,7 @@ public function indexDocument(string $identifier) { $this->logger->info('Start indexing single record.', [$identifier]); try { - $record = $this->getRecord((int)$identifier); + $record = $this->getRecord((int) $identifier); $this->prepareRecord($record); $this->connection->addDocument($this->getDocumentName(), $record); @@ -116,7 +116,7 @@ public function delete() $this->logger->info('Finish deletion.'); } - protected function getRecordGenerator(): \Generator + protected function getRecordGenerator() : \Generator { $offset = 0; $limit = $this->getLimit(); @@ -134,7 +134,7 @@ protected function prepareRecord(array &$record) $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier); } } catch (InvalidArgumentException $e) { - // Nothing to do + // Nothing to do. } $this->handleAbstract($record); @@ -166,7 +166,7 @@ protected function handleAbstract(array &$record) /** * Returns the limit to use to fetch records. */ - protected function getLimit(): int + protected function getLimit() : int { // TODO: Make configurable. return 50; @@ -180,7 +180,7 @@ abstract protected function getRecords(int $offset, int $limit); /** * @throws NoRecordFoundException If record could not be found. */ - abstract protected function getRecord(int $identifier): array; + abstract protected function getRecord(int $identifier) : array; - abstract protected function getDocumentName(): string; + abstract protected function getDocumentName() : string; } From 96a1db31ede5c43298f23d55b4afe5a7c325a910 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 6 Jun 2019 13:41:56 +0200 Subject: [PATCH 34/36] Remove unnecessary complexity from install There is no need to require anything, as only a single TYPO3 version is supported. --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 360db77c..77f3ad9a 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,7 @@ typo3DatabaseHost ?= "127.0.0.1" .PHONY: install install: clean - COMPOSER_PROCESS_TIMEOUT=1000 composer require --dev typo3/cms-core="$(TYPO3_VERSION)" - git checkout composer.json + composer install cgl: ./.Build/bin/phpcs From f7e748877b474f2c8bda3e2c2ba2ffe927071c49 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 6 Jun 2019 15:25:41 +0200 Subject: [PATCH 35/36] Fix pagination for CMS 9 --- Classes/Domain/Model/SearchRequest.php | 185 +++++++++++++++++++------ 1 file changed, 141 insertions(+), 44 deletions(-) diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php index d5cdf420..108a7cf1 100644 --- a/Classes/Domain/Model/SearchRequest.php +++ b/Classes/Domain/Model/SearchRequest.php @@ -23,21 +23,21 @@ use Codappix\SearchCore\Connection\ConnectionInterface; use Codappix\SearchCore\Connection\FacetRequestInterface; use Codappix\SearchCore\Connection\SearchRequestInterface; -use Codappix\SearchCore\Domain\Model\Query; use Codappix\SearchCore\Domain\Search\SearchService; -use TYPO3\CMS\Extbase\Persistence\QueryInterface; /** * Represents a search request used to process an actual search. */ class SearchRequest implements SearchRequestInterface { + use QueryResultInterfaceStub; + /** * The search string provided by the user, the actual term to search for. * * @var string */ - protected $queryString = ''; + protected $query = ''; /** * @var array @@ -50,9 +50,14 @@ class SearchRequest implements SearchRequestInterface protected $facets = []; /** - * @var Query + * @var int + */ + protected $offset = 0; + + /** + * @var int */ - private $query; + protected $limit = 10; /** * Used for QueryInterface implementation to allow execute method to work. @@ -69,15 +74,19 @@ class SearchRequest implements SearchRequestInterface /** * @param string $query */ - public function __construct(string $queryString = '') + public function __construct(string $query = '') { - $this->queryString = $queryString; - $this->query = new Query(); + $this->query = $query; + } + + public function getQuery() : string + { + return $this->query; } public function getSearchTerm() : string { - return $this->queryString; + return $this->query; } /** @@ -132,94 +141,182 @@ public function setSearchService(SearchService $searchService) $this->searchService = $searchService; } - public function setLimit(int $limit) + // Extbase QueryInterface + // Current implementation covers only paginate widget support. + public function execute($returnRawQueryResult = false) + { + if (! ($this->connection instanceof ConnectionInterface)) { + throw new \InvalidArgumentException( + 'Connection was not set before, therefore execute can not work. Use `setConnection` before.', + 1502197732 + ); + } + if (! ($this->searchService instanceof SearchService)) { + throw new \InvalidArgumentException( + 'SearchService was not set before, therefore execute can not work. Use `setSearchService` before.', + 1520325175 + ); + } + + return $this->searchService->processResult($this->connection->search($this)); + } + + public function setLimit($limit) { - $this->query->setLimit($limit); + $this->limit = (int) $limit; return $this; } - public function setOffset(int $offset) + public function setOffset($offset) { - $this->query->setOffset($offset); + $this->offset = (int) $offset; return $this; } - public function getLimit() : int + public function getLimit(): int { - return $this->query->getLimit(); + return $this->limit; } - public function getOffset() : int + public function getOffset(): int { - return $this->query->getOffset(); + return $this->offset; } - // Implementation of QueryResultInterface + public function getSource() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196146); + } - public function getQuery(): QueryInterface + public function setOrderings(array $orderings) { - return $this->query; + throw new \BadMethodCallException('Method is not implemented yet.', 1502196163); } - /** - * Returns the first object in the result set - * - * @return object - */ - public function getFirst() + public function matching($constraint) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196197); } - /** - * Returns an array with the objects in the result set - * - * @return array - */ - public function toArray() + public function logicalAnd($constraint1) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); } - public function count(): int + public function logicalOr($constraint1) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196198); } - public function current(): mixed + public function logicalNot(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); } - public function key() + public function equals($propertyName, $operand, $caseSensitive = true) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); + } + + public function contains($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196200); + } + + public function in($propertyName, $operand) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196167); + } + + public function lessThan($propertyName, $operand) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196201); } - public function next(): void + public function lessThanOrEqual($propertyName, $operand) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); } - public function rewind(): void + public function greaterThan($propertyName, $operand) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196202); } - public function valid(): bool + public function greaterThanOrEqual($propertyName, $operand) { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); } - public function offsetExists($offset): bool + public function getType() { - // TODO: Implement - return false; + throw new \BadMethodCallException('Method is not implemented yet.', 1502196203); } - public function offsetGet($offset): mixed + public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); + } + + public function getQuerySettings() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196205); + } + + public function count() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196169); + } + + public function getOrderings() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196206); + } + + public function getConstraint() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196171); + } + + public function isEmpty($propertyName) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196207); + } + + public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source) + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196172); + } + + public function getStatement() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); + } + + public function current() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); + } + + public function next() + { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); + } + + public function key() { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); } - public function offsetSet($offset, $value) : void + public function valid() { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); } - public function offsetUnset($offset): void + public function rewind() { + throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); } } From 2b888a2d0700d16a676549eab1d1601d1e8c8bea Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 6 Jun 2019 16:26:32 +0200 Subject: [PATCH 36/36] Cleanup code base for CMS 9 * Remove no longer necessary code. * Improve changelog for cms 9. --- Classes/Domain/Index/AbstractIndexer.php | 2 - Classes/Domain/Model/Query.php | 198 ------------------ .../1.0.0/20190517-typo3-v9-update.rst | 7 +- 3 files changed, 5 insertions(+), 202 deletions(-) delete mode 100644 Classes/Domain/Model/Query.php diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 88b11972..b22c0110 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -23,8 +23,6 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\ConnectionInterface; -use TYPO3\CMS\Core\Exception; -use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException; use TYPO3\CMS\Core\Utility\GeneralUtility; abstract class AbstractIndexer implements IndexerInterface diff --git a/Classes/Domain/Model/Query.php b/Classes/Domain/Model/Query.php deleted file mode 100644 index ab948061..00000000 --- a/Classes/Domain/Model/Query.php +++ /dev/null @@ -1,198 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use TYPO3\CMS\Extbase\Persistence\QueryInterface; - -/** - * Extbase QueryInterface - * Current implementation covers only paginate widget support. - */ -class Query implements QueryInterface -{ - /** - * @var int - */ - private $offset = 0; - - /** - * @var int - */ - private $limit = 10; - - public function execute($returnRawQueryResult = false) - { - if (! ($this->connection instanceof ConnectionInterface)) { - throw new \InvalidArgumentException( - 'Connection was not set before, therefore execute can not work. Use `setConnection` before.', - 1502197732 - ); - } - if (! ($this->searchService instanceof SearchService)) { - throw new \InvalidArgumentException( - 'SearchService was not set before, therefore execute can not work. Use `setSearchService` before.', - 1520325175 - ); - } - - return $this->searchService->processResult($this->connection->search($this)); - } - - public function setLimit($limit) - { - $this->limit = (int) $limit; - - return $this; - } - - public function setOffset($offset) - { - $this->offset = (int) $offset; - - return $this; - } - - public function getLimit() - { - return $this->limit; - } - - public function getOffset() - { - return $this->offset; - } - - public function getSource() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196146); - } - - public function setOrderings(array $orderings) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196163); - } - - public function matching($constraint) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196197); - } - - public function logicalAnd($constraint1) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); - } - - public function logicalOr($constraint1) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196198); - } - - public function logicalNot(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196166); - } - - public function equals($propertyName, $operand, $caseSensitive = true) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); - } - - public function like($propertyName, $operand, $caseSensitive = true) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196199); - } - - public function contains($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196200); - } - - public function in($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196167); - } - - public function lessThan($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196201); - } - - public function lessThanOrEqual($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); - } - - public function greaterThan($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196202); - } - - public function greaterThanOrEqual($propertyName, $operand) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); - } - - public function getType() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196203); - } - - public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196168); - } - - public function getQuerySettings() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196205); - } - - public function count() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196169); - } - - public function getOrderings() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196206); - } - - public function getConstraint() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196171); - } - - public function isEmpty($propertyName) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196207); - } - - public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source) - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196172); - } - - public function getStatement() - { - throw new \BadMethodCallException('Method is not implemented yet.', 1502196208); - } -} diff --git a/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst b/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst index bbd1f477..b434a131 100644 --- a/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst +++ b/Documentation/source/changelog/1.0.0/20190517-typo3-v9-update.rst @@ -9,8 +9,9 @@ This change contains some breaking changes: * Due to dropped TYPO3 CMS < v9 support, also all PHP Code within ``Compatibility`` namespace was removed. -* Fluid variable ``{request.query}`` is no longer provided, due to internal API - changes. Use ``{request.searchTerm}`` instead. + * ``\Codappix\SearchCore\DataProcessing\ContentObjectDataProcessorAdapterProcessor`` + has changed signature for ``__construct`` due to removed ``Compatibility`` + namespace. * PHP Interface ``\Codappix\SearchCore\Connection\SearchRequestInterface`` has changed, due to extending TYPO3 Interface @@ -18,3 +19,5 @@ This change contains some breaking changes: Therefore also PHP class ``\Codappix\SearchCore\Domain\Model\SearchRequest`` has been adjusted. + +* Recycler are respected. Pages from type recycler are ignored during indexing.