From 7cb160e5498e89c04dadb8ff789df0a0af0d346d Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 10 Apr 2018 17:17:16 +0200 Subject: [PATCH 1/9] TASK: Fix some small errors in changelog Fix wrong month used in changelog. Fix typos in headlines of changelog. Keep same case for features. --- Documentation/source/changelog.rst | 10 +++++----- ...ration.rst => 20180306-120-facet-configuration.rst} | 4 ++-- ...r.rst => 20180308-131-respect-page-cache-clear.rst} | 0 ...nts.rst => 20180308-introduce-php70-type-hints.rst} | 4 ++-- ...id.rst => 20180309-25-provide-sys-language-uid.rst} | 2 +- ...> 20180315-134-make-conent-fields-configurable.rst} | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename Documentation/source/changelog/{20180406-120-facet-configuration.rst => 20180306-120-facet-configuration.rst} (93%) rename Documentation/source/changelog/{20180408-131-respect-page-cache-clear.rst => 20180308-131-respect-page-cache-clear.rst} (100%) rename Documentation/source/changelog/{20180408-introduce-php70-type-hints.rst => 20180308-introduce-php70-type-hints.rst} (82%) rename Documentation/source/changelog/{20180409-25-provide-sys-language-uid.rst => 20180309-25-provide-sys-language-uid.rst} (91%) rename Documentation/source/changelog/{20180415-134-make-conent-fields-configurable.rst => 20180315-134-make-conent-fields-configurable.rst} (88%) diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst index 8b1c649..61756c6 100644 --- a/Documentation/source/changelog.rst +++ b/Documentation/source/changelog.rst @@ -5,8 +5,8 @@ Changelog :maxdepth: 1 :glob: - changelog/20180415-134-make-conent-fields-configurable - changelog/20180409-25-provide-sys-language-uid - changelog/20180408-131-respect-page-cache-clear - changelog/20180408-introduce-php70-type-hints - changelog/20180406-120-facet-configuration + 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 diff --git a/Documentation/source/changelog/20180406-120-facet-configuration.rst b/Documentation/source/changelog/20180306-120-facet-configuration.rst similarity index 93% rename from Documentation/source/changelog/20180406-120-facet-configuration.rst rename to Documentation/source/changelog/20180306-120-facet-configuration.rst index 0c2338f..88c36d0 100644 --- a/Documentation/source/changelog/20180406-120-facet-configuration.rst +++ b/Documentation/source/changelog/20180306-120-facet-configuration.rst @@ -1,5 +1,5 @@ -Breacking Change 120 "Pass facets configuration to Elasticsearch" -================================================================= +Breaking Change 120 "Pass facets configuration to Elasticsearch" +================================================================ In order to allow arbitrary facet configuration, we do not process the facet configuration anymore. Instead integrators are able to configure facets for search service "as is". We just pipe the diff --git a/Documentation/source/changelog/20180408-131-respect-page-cache-clear.rst b/Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst similarity index 100% rename from Documentation/source/changelog/20180408-131-respect-page-cache-clear.rst rename to Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst diff --git a/Documentation/source/changelog/20180408-introduce-php70-type-hints.rst b/Documentation/source/changelog/20180308-introduce-php70-type-hints.rst similarity index 82% rename from Documentation/source/changelog/20180408-introduce-php70-type-hints.rst rename to Documentation/source/changelog/20180308-introduce-php70-type-hints.rst index cc2dfe3..dae8b40 100644 --- a/Documentation/source/changelog/20180408-introduce-php70-type-hints.rst +++ b/Documentation/source/changelog/20180308-introduce-php70-type-hints.rst @@ -1,5 +1,5 @@ -Breacking Change "Introduce PHP 7.0 TypeHints" -============================================== +Breaking Change "Introduce PHP 7.0 TypeHints" +============================================= As PHP evolved, we now migrate the whole code base to use PHP 7.0 type hints. We do not use PHP 7.1 Type Hints, as some customers still need PHP 7.0 support. diff --git a/Documentation/source/changelog/20180409-25-provide-sys-language-uid.rst b/Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst similarity index 91% rename from Documentation/source/changelog/20180409-25-provide-sys-language-uid.rst rename to Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst index 3700ce0..5230b75 100644 --- a/Documentation/source/changelog/20180409-25-provide-sys-language-uid.rst +++ b/Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst @@ -1,4 +1,4 @@ -FEATURE 25 "Respect multiple languages" - Provide sys_language_uid +Feature 25 "Respect multiple languages" - Provide sys_language_uid ================================================================== Previously we did not fetch ``sys_language_uid`` field from database. This prevented everyone from diff --git a/Documentation/source/changelog/20180415-134-make-conent-fields-configurable.rst b/Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst similarity index 88% rename from Documentation/source/changelog/20180415-134-make-conent-fields-configurable.rst rename to Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst index 7068119..2601a71 100644 --- a/Documentation/source/changelog/20180415-134-make-conent-fields-configurable.rst +++ b/Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst @@ -1,4 +1,4 @@ -FEATURE 134 "Enable indexing of tt_content records of CType Header" +Feature 134 "Enable indexing of tt_content records of CType Header" =================================================================== Before, only ``bodytext`` was used to generate content while indexing pages. From c5da12f854d769c9d1ca0bc3debb14bfde5fca06 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 12 Apr 2018 08:27:41 +0200 Subject: [PATCH 2/9] TASK: Make travis pass elasticsearch start step Travis has installed elasticsearch already, we therefore need to REstart instead of start, as starting again will not work. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56f42fa..54c2637 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: 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 start + - 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;' language: php From 97c0485e6f85c1a31acec74f3d60160ea4dcaf33 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 12 Apr 2018 08:27:41 +0200 Subject: [PATCH 3/9] TASK: Make travis pass elasticsearch start step Travis has installed elasticsearch already, we therefore need to Restart instead of start, as starting again will not work. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56f42fa..54c2637 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ addons: 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 start + - 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;' language: php From 4234575c36dbfbf1bf13fac0c05aa8a26280398c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 12 Apr 2018 08:26:34 +0200 Subject: [PATCH 4/9] TASK: Fix broken tests caused by missing caches For some reason, which is unknown yet, caches are needed to make tests pass. We therefore configure the caches to be null. --- Tests/Unit/AbstractUnitTestCase.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Tests/Unit/AbstractUnitTestCase.php b/Tests/Unit/AbstractUnitTestCase.php index fa29d57..384236c 100644 --- a/Tests/Unit/AbstractUnitTestCase.php +++ b/Tests/Unit/AbstractUnitTestCase.php @@ -39,14 +39,9 @@ abstract class AbstractUnitTestCase extends CoreTestCase $this->singletonInstances = GeneralUtility::getSingletonInstances(); // Disable caching backends to make TYPO3 parts work in unit test mode. - \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Cache\CacheManager::class - )->setCacheConfigurations([ - 'extbase_object' => [ - 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, - ], - ]); + )->setCacheConfigurations($this->getCacheConfiguration()); } public function tearDown() @@ -100,4 +95,25 @@ abstract class AbstractUnitTestCase extends CoreTestCase { return \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 8000000; } + + protected function getCacheConfiguration() : array + { + $cacheConfiguration = [ + 'extbase_object' => [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + ], + 'cache_runtime' => [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + ], + ]; + + if (class_exists(\TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache::class)) { + $cacheConfiguration['fluid_template'] = [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + 'frontend' => \TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache::class, + ]; + } + + return $cacheConfiguration; + } } From c1d1e6ed68db911a1935d1b84a3e781b4188a223 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 1 Apr 2018 11:29:22 +0200 Subject: [PATCH 5/9] BUGFIX: Do not resolve inputDateTime as relation Add test which checks this behaviour. Exclude inputDateTime from relation resolving. Resolves #147 --- .../Index/TcaIndexer/RelationResolver.php | 2 +- .../Index/TcaIndexer/RelationResolverTest.php | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php diff --git a/Classes/Domain/Index/TcaIndexer/RelationResolver.php b/Classes/Domain/Index/TcaIndexer/RelationResolver.php index ae47e30..763589b 100644 --- a/Classes/Domain/Index/TcaIndexer/RelationResolver.php +++ b/Classes/Domain/Index/TcaIndexer/RelationResolver.php @@ -82,7 +82,7 @@ class RelationResolver implements Singleton protected function isRelation(array &$config) : bool { return isset($config['foreign_table']) - || (isset($config['renderType']) && $config['renderType'] !== 'selectSingle') + || (isset($config['renderType']) && !in_array($config['renderType'], ['selectSingle', 'inputDateTime'])) || (isset($config['internal_type']) && strtolower($config['internal_type']) === 'db') ; } diff --git a/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php b/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php new file mode 100644 index 0000000..c227c24 --- /dev/null +++ b/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php @@ -0,0 +1,83 @@ + + * + * 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\RelationResolver; +use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; +use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; + +class RelationResolverTest extends AbstractUnitTestCase +{ + /** + * @var RelationResolver + */ + protected $subject; + + public function setUp() + { + parent::setUp(); + $this->subject = new RelationResolver(); + } + + /** + * @test + */ + public function renderTypeInputDateTimeIsHandled() + { + $originalRecord = [ + 'starttime' => 0, + ]; + $record = $originalRecord; + $GLOBALS['TCA'] = [ + 'tt_content' => [ + 'columns' => [ + 'starttime' => [ + 'config' => [ + 'default' => 0, + 'eval' => 'datetime', + 'renderType' => 'inputDateTime', + ], + 'type' => 'input', + 'exclude' => 1, + 'l10n_display' => 'defaultAsReadonly', + 'l10n_mode' => 'exclude', + 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.starttime', + ], + ], + ], + ]; + $tableServiceMock = $this->getMockBuilder(TcaTableServiceInterface::class)->getMock(); + $tableServiceMock->expects($this->any()) + ->method('getTableName') + ->willReturn('tt_content'); + $tableServiceMock->expects($this->any()) + ->method('getColumnConfig') + ->willReturn($GLOBALS['TCA']['tt_content']['columns']['starttime']['config']); + + $this->subject->resolveRelationsForRecord($tableServiceMock, $record); + + $this->assertSame( + $originalRecord, + $record, + 'TCA column configured with renderType inputDateTime was not kept as unix timestamp.' + ); + } +} From 82d397c4287af728c8460ba53495fb328f4a421f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 1 Apr 2018 11:13:23 +0200 Subject: [PATCH 6/9] FEATURE: Keep sys_language_uid while indexing Before this change, sys_language_uid was indexed as an empty string, due to internal used TYPO3 API. We now skip the configure field which defines language uid. This way you can build filter based on current language. Resolves #148 --- .../Index/TcaIndexer/RelationResolver.php | 3 +- .../Index/TcaIndexer/TcaTableService.php | 9 ++ .../Index/TcaIndexer/TcaTableService76.php | 9 ++ .../TcaIndexer/TcaTableServiceInterface.php | 2 + Documentation/source/changelog.rst | 1 + .../20180410-148-keep-sys_language_uid.rst | 10 ++ Tests/Functional/Indexing/TcaIndexerTest.php | 6 +- .../Index/TcaIndexer/RelationResolverTest.php | 92 +++++++++++++++++++ 8 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst create mode 100644 Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php diff --git a/Classes/Domain/Index/TcaIndexer/RelationResolver.php b/Classes/Domain/Index/TcaIndexer/RelationResolver.php index ae47e30..378dc75 100644 --- a/Classes/Domain/Index/TcaIndexer/RelationResolver.php +++ b/Classes/Domain/Index/TcaIndexer/RelationResolver.php @@ -37,7 +37,8 @@ class RelationResolver implements Singleton { foreach (array_keys($record) as $column) { // TODO: Define / configure fields to exclude?! - if ($column === 'pid') { + if (in_array($column, ['pid', $service->getLanguageUidColumn()])) { + $record[$column] = (int) $record[$column]; continue; } diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index ee0a2d8..37b0c89 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -283,6 +283,15 @@ class TcaTableService implements TcaTableServiceInterface 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. diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php b/Classes/Domain/Index/TcaIndexer/TcaTableService76.php index f52027a..59d6136 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService76.php @@ -290,6 +290,15 @@ class TcaTableService76 implements TcaTableServiceInterface 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. diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableServiceInterface.php b/Classes/Domain/Index/TcaIndexer/TcaTableServiceInterface.php index 0c9cfc4..e4ee7c5 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableServiceInterface.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableServiceInterface.php @@ -41,4 +41,6 @@ interface TcaTableServiceInterface public function getRecords(int $offset, int $limit) : array; public function getRecord(int $identifier) : array; + + public function getLanguageUidColumn() : string; } diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst index 61756c6..37b42c6 100644 --- a/Documentation/source/changelog.rst +++ b/Documentation/source/changelog.rst @@ -5,6 +5,7 @@ Changelog :maxdepth: 1 :glob: + 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 diff --git a/Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst b/Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst new file mode 100644 index 0000000..d89a289 --- /dev/null +++ b/Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst @@ -0,0 +1,10 @@ +Feature 148 "Cast sys_language_uid to int" +========================================== + +While resolving relations the configured language uid field, fetched from TCA, will +be casted to integer and returned immediately. + +This change prevents the bug mentioned in :issue:`148`, where `0` is casted to an +empty string, which makes filtering hard. + +See :issue:`148`. diff --git a/Tests/Functional/Indexing/TcaIndexerTest.php b/Tests/Functional/Indexing/TcaIndexerTest.php index d7ecc3a..85f36a6 100644 --- a/Tests/Functional/Indexing/TcaIndexerTest.php +++ b/Tests/Functional/Indexing/TcaIndexerTest.php @@ -103,11 +103,7 @@ class TcaIndexerTest extends AbstractFunctionalTestCase ->with( $this->stringContains('tt_content'), $this->callback(function ($documents) { - if ($this->isLegacyVersion()) { - return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === '2'; - } else { - return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === 2; - } + return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === 2; }) ); diff --git a/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php b/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php new file mode 100644 index 0000000..60732dd --- /dev/null +++ b/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php @@ -0,0 +1,92 @@ + + * + * 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\RelationResolver; +use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; +use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; + +class RelationResolverTest extends AbstractUnitTestCase +{ + /** + * @var RelationResolver + */ + protected $subject; + + public function setUp() + { + parent::setUp(); + $this->subject = new RelationResolver(); + } + + /** + * @test + */ + public function sysLanguageUidZeroIsKept() + { + $record = [ + 'sys_language_uid' => '0', + ]; + $GLOBALS['TCA'] = [ + 'tt_content' => [ + 'columns' => [ + 'sys_language_uid' => [ + 'config' => [ + 'default' => 0, + 'items' => [ + [ + 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', + '-1', + 'flags-multiple', + ], + ], + 'renderType' => 'selectSingle', + 'special' => 'languages', + 'type' => 'select', + 'exclude' => '1', + 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.language', + ], + ], + ], + ], + ]; + $tableServiceMock = $this->getMockBuilder(TcaTableServiceInterface::class)->getMock(); + $tableServiceMock->expects($this->any()) + ->method('getTableName') + ->willReturn('tt_content'); + $tableServiceMock->expects($this->any()) + ->method('getLanguageUidColumn') + ->willReturn('sys_language_uid'); + $tableServiceMock->expects($this->any()) + ->method('getColumnConfig') + ->willReturn($GLOBALS['TCA']['tt_content']['columns']['sys_language_uid']['config']); + + $this->subject->resolveRelationsForRecord($tableServiceMock, $record); + + $this->assertSame( + [ + 'sys_language_uid' => 0, + ], + $record, + 'sys_language_uid was not kept as zero.' + ); + } +} From dfb3f897e7e5e30c8ebba0d3dd0b69b1d14dcd7f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 24 Apr 2018 09:37:25 +0200 Subject: [PATCH 7/9] !!!|FEATURE: Extract relation resolver to data processor Instead of hardcoding and tight coupling of relation resolving, we now provide a dataprocessor instead. Therefore you need to configure resolving for each indexed type. This resolves #149 and #147. --- Classes/DataProcessing/Service.php | 6 +- .../TcaRelationResolvingProcessor.php | 101 +++++++++++++++++ Classes/Domain/Index/AbstractIndexer.php | 2 +- .../Domain/Index/TcaIndexer/PagesIndexer.php | 3 +- .../Index/TcaIndexer/RelationResolver.php | 5 +- .../Index/TcaIndexer/TcaTableService.php | 9 -- .../Index/TcaIndexer/TcaTableService76.php | 9 -- Documentation/source/changelog.rst | 1 + ...t-relation-resolver-to-data-processing.rst | 24 ++++ .../TcaRelationResolvingProcessor.rst | 34 ++++++ Documentation/source/dataprocessors.rst | 16 +-- .../TcaRelationResolvingProcessorTest.php} | 26 ++--- Tests/Functional/Fixtures/BasicSetup.ts | 8 ++ Tests/Functional/Indexing/TcaIndexerTest.php | 32 ------ Tests/Unit/Bootstrap.php | 2 + .../TcaRelationResolvingProcessorTest.php} | 105 ++++++++++++------ 16 files changed, 262 insertions(+), 121 deletions(-) create mode 100644 Classes/DataProcessing/TcaRelationResolvingProcessor.php create mode 100644 Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst create mode 100644 Documentation/source/configuration/dataProcessing/TcaRelationResolvingProcessor.rst rename Tests/Functional/{Indexing/TcaIndexer/RelationResolverTest.php => DataProcessing/TcaRelationResolvingProcessorTest.php} (77%) rename Tests/Unit/{Domain/Index/TcaIndexer/RelationResolverTest.php => DataProcessing/TcaRelationResolvingProcessorTest.php} (53%) diff --git a/Classes/DataProcessing/Service.php b/Classes/DataProcessing/Service.php index 3e3b053..5369b86 100644 --- a/Classes/DataProcessing/Service.php +++ b/Classes/DataProcessing/Service.php @@ -42,7 +42,7 @@ class Service * * @param array|string $configuration Either the full configuration or only the class name. */ - public function executeDataProcessor($configuration, array $data) : array + public function executeDataProcessor($configuration, array $data, string $recordType = '') : array { if (is_string($configuration)) { $configuration = [ @@ -50,6 +50,10 @@ class Service ]; } + if (!isset($configuration['_table']) && $recordType !== '') { + $configuration['_table'] = $recordType; + } + return $this->objectManager->get($configuration['_typoScriptNodeValue']) ->processData($data, $configuration); } diff --git a/Classes/DataProcessing/TcaRelationResolvingProcessor.php b/Classes/DataProcessing/TcaRelationResolvingProcessor.php new file mode 100644 index 0000000..e111d7d --- /dev/null +++ b/Classes/DataProcessing/TcaRelationResolvingProcessor.php @@ -0,0 +1,101 @@ + + * + * 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\RelationResolver; +use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; + +/** + * Resolves relations from TCA using RelationResolver. + */ +class TcaRelationResolvingProcessor implements ProcessorInterface +{ + /** + * @var ObjectManagerInterface + */ + protected $objectManager; + + /** + * @var RelationResolver + */ + protected $relationResolver; + + public function __construct( + ObjectManagerInterface $objectManager, + RelationResolver $relationResolver + ) { + $this->objectManager = $objectManager; + $this->relationResolver = $relationResolver; + } + + /** + * @throws \InvalidArgumentException If _table is not configured. + */ + public function processData(array $record, array $configuration) : array + { + $this->initializeConfiguration($configuration); + + $tcaTableService = $this->objectManager->get( + TcaTableServiceInterface::class, + $configuration['_table'] + ); + + $processedRecord = $this->relationResolver->resolveRelationsForRecord( + $tcaTableService, + $this->getRecordToProcess($record, $configuration) + ); + + return array_merge($record, $processedRecord); + } + + /** + * @throws \InvalidArgumentException If _table is not configured. + */ + protected function initializeConfiguration(array &$configuration) + { + if (!isset($configuration['_table'])) { + throw new \InvalidArgumentException('The configuration "_table" is mandantory.', 1524552631); + } + + if (!isset($configuration['excludeFields'])) { + $configuration['excludeFields'] = ''; + } + + $configuration['excludeFields'] = GeneralUtility::trimExplode(',', $configuration['excludeFields'], true); + } + + protected function getRecordToProcess(array $record, array $configuration) : array + { + if ($configuration['excludeFields'] === []) { + return $record; + } + + $newRecord = []; + $keysToUse = array_diff(array_keys($record), $configuration['excludeFields']); + foreach ($keysToUse as $keyToUse) { + $newRecord[$keyToUse] = $record[$keyToUse]; + } + + return $newRecord; + } +} diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 6644716..b22c011 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -129,7 +129,7 @@ abstract class AbstractIndexer implements IndexerInterface { try { foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) { - $record = $this->dataProcessorService->executeDataProcessor($configuration, $record); + $record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier); } } catch (InvalidArgumentException $e) { // Nothing to do. diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php index 9cd4764..af1d129 100644 --- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php +++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php @@ -60,6 +60,8 @@ class PagesIndexer extends TcaIndexer protected function prepareRecord(array &$record) { + parent::prepareRecord($record); + $possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title']; foreach ($possibleTitleFields as $searchTitleField) { if (isset($record[$searchTitleField]) && trim($record[$searchTitleField])) { @@ -74,7 +76,6 @@ class PagesIndexer extends TcaIndexer $record['content'] = $content['content']; $record['media'] = array_values(array_unique(array_merge($record['media'], $content['images']))); } - parent::prepareRecord($record); } protected function fetchContentForPage(int $uid) : array diff --git a/Classes/Domain/Index/TcaIndexer/RelationResolver.php b/Classes/Domain/Index/TcaIndexer/RelationResolver.php index 256a135..ae10f68 100644 --- a/Classes/Domain/Index/TcaIndexer/RelationResolver.php +++ b/Classes/Domain/Index/TcaIndexer/RelationResolver.php @@ -33,10 +33,9 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; */ class RelationResolver implements Singleton { - public function resolveRelationsForRecord(TcaTableServiceInterface $service, array &$record) + public function resolveRelationsForRecord(TcaTableServiceInterface $service, array $record) : array { foreach (array_keys($record) as $column) { - // TODO: Define / configure fields to exclude?! if (in_array($column, ['pid', $service->getLanguageUidColumn()])) { $record[$column] = (int) $record[$column]; continue; @@ -62,6 +61,8 @@ class RelationResolver implements Singleton continue; } } + + return $record; } protected function resolveValue($value, array $tcaColumn) diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index 37b0c89..1330e22 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -54,11 +54,6 @@ class TcaTableService implements TcaTableServiceInterface */ protected $configuration; - /** - * @var RelationResolver - */ - protected $relationResolver; - /** * @var \TYPO3\CMS\Core\Log\Logger */ @@ -93,7 +88,6 @@ class TcaTableService implements TcaTableServiceInterface */ public function __construct( $tableName, - RelationResolver $relationResolver, ConfigurationContainerInterface $configuration ) { if (!isset($GLOBALS['TCA'][$tableName])) { @@ -106,7 +100,6 @@ class TcaTableService implements TcaTableServiceInterface $this->tableName = $tableName; $this->tca = &$GLOBALS['TCA'][$this->tableName]; $this->configuration = $configuration; - $this->relationResolver = $relationResolver; } public function getTableName() : string @@ -151,8 +144,6 @@ class TcaTableService implements TcaTableServiceInterface public function prepareRecord(array &$record) { - $this->relationResolver->resolveRelationsForRecord($this, $record); - if (isset($record['uid']) && !isset($record['search_identifier'])) { $record['search_identifier'] = $record['uid']; } diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php b/Classes/Domain/Index/TcaIndexer/TcaTableService76.php index 59d6136..4445d6d 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService76.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService76.php @@ -50,11 +50,6 @@ class TcaTableService76 implements TcaTableServiceInterface */ protected $configuration; - /** - * @var RelationResolver - */ - protected $relationResolver; - /** * @var \TYPO3\CMS\Core\Log\Logger */ @@ -89,7 +84,6 @@ class TcaTableService76 implements TcaTableServiceInterface */ public function __construct( $tableName, - RelationResolver $relationResolver, ConfigurationContainerInterface $configuration ) { if (!isset($GLOBALS['TCA'][$tableName])) { @@ -102,7 +96,6 @@ class TcaTableService76 implements TcaTableServiceInterface $this->tableName = $tableName; $this->tca = &$GLOBALS['TCA'][$this->tableName]; $this->configuration = $configuration; - $this->relationResolver = $relationResolver; } public function getTableName() : string @@ -157,8 +150,6 @@ class TcaTableService76 implements TcaTableServiceInterface public function prepareRecord(array &$record) { - $this->relationResolver->resolveRelationsForRecord($this, $record); - if (isset($record['uid']) && !isset($record['search_identifier'])) { $record['search_identifier'] = $record['uid']; } diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst index 37b42c6..27e6fab 100644 --- a/Documentation/source/changelog.rst +++ b/Documentation/source/changelog.rst @@ -5,6 +5,7 @@ Changelog :maxdepth: 1 :glob: + 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 diff --git a/Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst b/Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst new file mode 100644 index 0000000..6aff516 --- /dev/null +++ b/Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst @@ -0,0 +1,24 @@ +Breaking Change 149 "Extract RelationResolver to a new DataProcessor" +===================================================================== + +The resolving of relation, based on TCA, is no longer done by the indexer. Instead we +now provide a DataProcessor to solve this job. + +As this makes it necessary to configure the DataProcessor, this is a breaking change. +Before the resolving was done out of the box. + +So why did we change that? The resolving of relations was already implemented before +we added the data processors. As the concept of data processors is far more flexible, +we try to migrate hard coupled components step by step. The benefit of this change is +basically that you can now configure the resolving of relations and far more +important, the order of execution. + +Now it's possible to first copy some fields, e.g. ``starttime`` and ``endtime`` to +further fields and to resolve relations afterwards. As the copied fields are not +configured in TCA, they will be skipped. This way an integrator can keep certain +information as they are. + +Also the processor is now configured as all other processors. You can now optionally +configure fields to not process. + +See :issue:`149` and :issue:`147`. diff --git a/Documentation/source/configuration/dataProcessing/TcaRelationResolvingProcessor.rst b/Documentation/source/configuration/dataProcessing/TcaRelationResolvingProcessor.rst new file mode 100644 index 0000000..a5814d3 --- /dev/null +++ b/Documentation/source/configuration/dataProcessing/TcaRelationResolvingProcessor.rst @@ -0,0 +1,34 @@ +``Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor`` +==================================================================== + +Will resolve relations through TCA for record. +The result will be the same as in list view of TYPO3 Backend. E.g. Check boxes will be +resolved to their label, dates will be resolved to human readable representation and +relations will be resolved to their configured labels. + +Combine with CopyToProcessor or exclude certain fields to keep original value for +further processing. + +Mandatory Options: + +``_table`` + The TCA table as found on top level of ``$GLOBALS['TCA']``. + + This will auto filled for indexing through the provided indexers. Still you can + apply processors on results, where no information about the table exists anymore. + +Possible Options: + +``excludeFields`` + Comma separated list of fields to not resolve relations for. + +Example:: + + plugin.tx_searchcore.settings.indexing.tt_content.dataProcessing { + 1 = Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor + 1 { + _table = tt_content + excludeFields = starttime, endtime + } + } + diff --git a/Documentation/source/dataprocessors.rst b/Documentation/source/dataprocessors.rst index 67ff655..2023ff2 100644 --- a/Documentation/source/dataprocessors.rst +++ b/Documentation/source/dataprocessors.rst @@ -66,6 +66,7 @@ Available DataProcessors /configuration/dataProcessing/CopyToProcessor /configuration/dataProcessing/GeoPointProcessor /configuration/dataProcessing/RemoveProcessor + /configuration/dataProcessing/TcaRelationResolvingProcessor .. _dataprocessors_plannedDataProcessors: @@ -81,18 +82,3 @@ Planned DataProcessors ``Codappix\SearchCore\DataProcessing\ChannelProcessor`` Will add a configurable channel to the record, e.g. if you have different areas in your website like "products" and "infos". - - ``Codappix\SearchCore\DataProcessing\RelationResolverProcessor`` - Resolves all relations using the TCA. - This is currently done through indexer. - -.. Of course you are able to provide further processors. Just implement -.. ``Codappix\SearchCore\DataProcessing\ProcessorInterface`` and use the FQCN (=Fully qualified -.. class name) as done in the examples above. - -.. By implementing also the same interface as necessary for TYPO3 -.. :ref:`t3tsref:cobj-fluidtemplate-properties-dataprocessing`, you are able to reuse the same code -.. also for Fluid to prepare the same record fetched from DB for your fluid. - -.. Dependency injection is possible inside of processors, as we instantiate through extbase -.. ``ObjectManager``. diff --git a/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php similarity index 77% rename from Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php rename to Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php index a491677..c5011df 100644 --- a/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php +++ b/Tests/Functional/DataProcessing/TcaRelationResolvingProcessorTest.php @@ -1,5 +1,5 @@ @@ -20,13 +20,13 @@ namespace Codappix\SearchCore\Tests\Indexing\TcaIndexer; * 02110-1301, USA. */ -use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService; +use Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor; use Codappix\SearchCore\Tests\Functional\AbstractFunctionalTestCase; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; -class RelationResolverTest extends AbstractFunctionalTestCase +class TcaRelationResolvingProcessorTest extends AbstractFunctionalTestCase { /** * @test @@ -37,9 +37,8 @@ class RelationResolverTest extends AbstractFunctionalTestCase $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'sys_file'; - $subject = $objectManager->get(TcaTableService::class, $table); - $record = BackendUtility::getRecord($table, 1); - $subject->prepareRecord($record); + $subject = $objectManager->get(TcaRelationResolvingProcessor::class); + $record = $subject->processData(BackendUtility::getRecord($table, 1), ['_table' => $table]); $this->assertEquals( [ @@ -60,9 +59,8 @@ class RelationResolverTest extends AbstractFunctionalTestCase $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; - $subject = $objectManager->get(TcaTableService::class, $table); - $record = BackendUtility::getRecord($table, 1); - $subject->prepareRecord($record); + $subject = $objectManager->get(TcaRelationResolvingProcessor::class); + $record = $subject->processData(BackendUtility::getRecord($table, 1), ['_table' => $table]); $this->assertEquals( 'Insert Plugin', @@ -80,9 +78,8 @@ class RelationResolverTest extends AbstractFunctionalTestCase $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; - $subject = $objectManager->get(TcaTableService::class, $table); - $record = BackendUtility::getRecord($table, 1); - $subject->prepareRecord($record); + $subject = $objectManager->get(TcaRelationResolvingProcessor::class); + $record = $subject->processData(BackendUtility::getRecord($table, 1), ['_table' => $table]); $this->assertEquals( [ @@ -103,9 +100,8 @@ class RelationResolverTest extends AbstractFunctionalTestCase $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $table = 'tt_content'; - $subject = $objectManager->get(TcaTableService::class, $table); - $record = BackendUtility::getRecord($table, 1); - $subject->prepareRecord($record); + $subject = $objectManager->get(TcaRelationResolvingProcessor::class); + $record = $subject->processData(BackendUtility::getRecord($table, 1), ['_table' => $table]); $this->assertEquals( [ diff --git a/Tests/Functional/Fixtures/BasicSetup.ts b/Tests/Functional/Fixtures/BasicSetup.ts index 840a7b8..a4a26fb 100644 --- a/Tests/Functional/Fixtures/BasicSetup.ts +++ b/Tests/Functional/Fixtures/BasicSetup.ts @@ -22,6 +22,10 @@ plugin { type = keyword } } + + dataProcessing { + 1 = Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor + } } pages { @@ -34,6 +38,10 @@ plugin { type = keyword } } + + dataProcessing { + 1 = Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor + } } } diff --git a/Tests/Functional/Indexing/TcaIndexerTest.php b/Tests/Functional/Indexing/TcaIndexerTest.php index 85f36a6..472cc15 100644 --- a/Tests/Functional/Indexing/TcaIndexerTest.php +++ b/Tests/Functional/Indexing/TcaIndexerTest.php @@ -77,36 +77,4 @@ class TcaIndexerTest extends AbstractFunctionalTestCase $objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments(); } - - /** - * @test - */ - public function sysLanguageIsKept() - { - $this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/KeepSysLanguageUid.xml'); - $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class); - $tableName = 'tt_content'; - $tableService = $objectManager->get( - TcaTableServiceInterface::class, - $tableName, - $objectManager->get(RelationResolver::class), - $objectManager->get(ConfigurationContainerInterface::class) - ); - - $connection = $this->getMockBuilder(Elasticsearch::class) - ->setMethods(['addDocuments']) - ->disableOriginalConstructor() - ->getMock(); - - $connection->expects($this->once()) - ->method('addDocuments') - ->with( - $this->stringContains('tt_content'), - $this->callback(function ($documents) { - return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === 2; - }) - ); - - $objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments(); - } } diff --git a/Tests/Unit/Bootstrap.php b/Tests/Unit/Bootstrap.php index 0f7b382..3ed0a1c 100644 --- a/Tests/Unit/Bootstrap.php +++ b/Tests/Unit/Bootstrap.php @@ -6,4 +6,6 @@ if (getenv('TYPO3_VERSION') === '~7.6') { $filePath = '.Build/vendor/typo3/cms/typo3/sysext/core/Build/UnitTestsBootstrap.php'; } +date_default_timezone_set('UTC'); + require_once dirname(dirname(__DIR__)) . '/' . $filePath; diff --git a/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php b/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php similarity index 53% rename from Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php rename to Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php index 663f7ca..e7abb07 100644 --- a/Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php +++ b/Tests/Unit/DataProcessing/TcaRelationResolvingProcessorTest.php @@ -1,5 +1,5 @@ @@ -20,21 +20,46 @@ namespace Codappix\SearchCore\Tests\Unit\Domain\Index\TcaIndexer; * 02110-1301, USA. */ -use Codappix\SearchCore\Domain\Index\TcaIndexer\RelationResolver; -use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface; +use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; +use Codappix\SearchCore\DataProcessing\TcaRelationResolvingProcessor; use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase; +use TYPO3\CMS\Extbase\Object\ObjectManager; +use \TYPO3\CMS\Core\Utility\GeneralUtility; -class RelationResolverTest extends AbstractUnitTestCase +class TcaRelationResolvingProcessorTest extends AbstractUnitTestCase { /** - * @var RelationResolver + * @var TcaRelationResolvingProcessor */ protected $subject; + /** + * @var ConfigurationContainerInterface + */ + protected $configurationMock; + public function setUp() { parent::setUp(); - $this->subject = new RelationResolver(); + $this->configurationMock = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock(); + + GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class) + ->registerImplementation( + ConfigurationContainerInterface::class, + get_class($this->configurationMock) + ); + + $this->subject = GeneralUtility::makeInstance(ObjectManager::class) + ->get(TcaRelationResolvingProcessor::class); + } + + /** + * @test + */ + public function exceptionIsThrownIfTableIsNotConfigured() + { + $this->expectException(\InvalidArgumentException::class); + $this->subject->processData([], []); } /** @@ -42,11 +67,17 @@ class RelationResolverTest extends AbstractUnitTestCase */ public function sysLanguageUidZeroIsKept() { - $record = [ + $originalRecord = [ 'sys_language_uid' => '0', ]; + $record = [ + 'sys_language_uid' => 0, + ]; $GLOBALS['TCA'] = [ 'tt_content' => [ + 'ctrl' => [ + 'languageField' => 'sys_language_uid', + ], 'columns' => [ 'sys_language_uid' => [ 'config' => [ @@ -68,19 +99,10 @@ class RelationResolverTest extends AbstractUnitTestCase ], ], ]; - $tableServiceMock = $this->getMockBuilder(TcaTableServiceInterface::class)->getMock(); - $tableServiceMock->expects($this->any()) - ->method('getTableName') - ->willReturn('tt_content'); - $tableServiceMock->expects($this->any()) - ->method('getLanguageUidColumn') - ->willReturn('sys_language_uid'); - $tableServiceMock->expects($this->any()) - ->method('getColumnConfig') - ->willReturn($GLOBALS['TCA']['tt_content']['columns']['sys_language_uid']['config']); - - $this->subject->resolveRelationsForRecord($tableServiceMock, $record); - + $configuration = [ + '_table' => 'tt_content', + ]; + $record = $this->subject->processData($originalRecord, $configuration); $this->assertSame( [ 'sys_language_uid' => 0, @@ -96,7 +118,8 @@ class RelationResolverTest extends AbstractUnitTestCase public function renderTypeInputDateTimeIsHandled() { $originalRecord = [ - 'starttime' => 0, + 'endtime' => 99999999999, + 'starttime' => 1523010960, ]; $record = $originalRecord; $GLOBALS['TCA'] = [ @@ -104,12 +127,24 @@ class RelationResolverTest extends AbstractUnitTestCase 'columns' => [ 'starttime' => [ 'config' => [ + 'type' => 'input', 'default' => 0, - 'eval' => 'datetime', + 'eval' => 'datetime,int', 'renderType' => 'inputDateTime', ], - 'type' => 'input', - 'exclude' => 1, + 'exclude' => true, + 'l10n_display' => 'defaultAsReadonly', + 'l10n_mode' => 'exclude', + 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.starttime', + ], + 'endtime' => [ + 'config' => [ + 'type' => 'input', + 'default' => 0, + 'eval' => 'datetime,int', + 'renderType' => 'inputDateTime', + ], + 'exclude' => true, 'l10n_display' => 'defaultAsReadonly', 'l10n_mode' => 'exclude', 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.starttime', @@ -117,20 +152,18 @@ class RelationResolverTest extends AbstractUnitTestCase ], ], ]; - $tableServiceMock = $this->getMockBuilder(TcaTableServiceInterface::class)->getMock(); - $tableServiceMock->expects($this->any()) - ->method('getTableName') - ->willReturn('tt_content'); - $tableServiceMock->expects($this->any()) - ->method('getColumnConfig') - ->willReturn($GLOBALS['TCA']['tt_content']['columns']['starttime']['config']); - - $this->subject->resolveRelationsForRecord($tableServiceMock, $record); - + $configuration = [ + '_table' => 'tt_content', + 'excludeFields' => 'starttime', + ]; + $record = $this->subject->processData($originalRecord, $configuration); $this->assertSame( - $originalRecord, + [ + 'endtime' => '16-11-38 09:46', + 'starttime' => 1523010960, + ], $record, - 'TCA column configured with renderType inputDateTime was not kept as unix timestamp.' + 'Exclude fields were not respected.' ); } } From ac615d830910cd530cab37017e16b35962947aa1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 26 Apr 2018 07:52:59 +0200 Subject: [PATCH 8/9] TASK: Raise version number --- Documentation/source/conf.py | 6 +++--- ext_emconf.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py index aa846e0..ae0b901 100644 --- a/Documentation/source/conf.py +++ b/Documentation/source/conf.py @@ -59,9 +59,9 @@ author = u'Daniel Siepmann' # built documents. # # The short X.Y version. -version = u'0.0.1' +version = u'0.0.4' # The full version, including alpha/beta/rc tags. -release = u'0.0.1' +release = u'0.0.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -133,7 +133,7 @@ html_theme_options = { # The name for this set of Sphinx documents. # " v documentation" by default. -#html_title = u'TYPO3 Extension search_core v0.0.1' +#html_title = u'TYPO3 Extension search_core v0.0.4' # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None diff --git a/ext_emconf.php b/ext_emconf.php index 7c3a087..b0b5e65 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -18,7 +18,7 @@ $EM_CONF[$_EXTKEY] = [ ], ], 'state' => 'beta', - 'version' => '0.0.1', + 'version' => '0.0.4', 'author' => 'Daniel Siepmann', 'author_email' => 'coding@daniel-siepmann.de', ]; From a2b0cf2c97241b72eb2787e3875bd4b1fa0cc289 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 26 Apr 2018 09:55:25 +0200 Subject: [PATCH 9/9] TASK: Fix version in install instruction --- Documentation/source/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/source/installation.rst b/Documentation/source/installation.rst index 174d9f7..fc9b479 100644 --- a/Documentation/source/installation.rst +++ b/Documentation/source/installation.rst @@ -9,7 +9,7 @@ Composer The extension can be installed through composer:: - composer require "codappix/search_core" "~0.0.3" + composer require "codappix/search_core" "~0.0.4" Note that you have to allow unstable packages: