Merge remote-tracking branch 'origin/develop' into feature/147-handle-rendertype-inputDateTime

Conflicts:
    Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php
This commit is contained in:
Daniel Siepmann 2018-04-19 17:08:13 +02:00
commit 0d57374f25
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
13 changed files with 98 additions and 17 deletions

View file

@ -37,7 +37,8 @@ class RelationResolver implements Singleton
{ {
foreach (array_keys($record) as $column) { foreach (array_keys($record) as $column) {
// TODO: Define / configure fields to exclude?! // TODO: Define / configure fields to exclude?!
if ($column === 'pid') { if (in_array($column, ['pid', $service->getLanguageUidColumn()])) {
$record[$column] = (int) $record[$column];
continue; continue;
} }

View file

@ -283,6 +283,15 @@ class TcaTableService implements TcaTableServiceInterface
return $this->tca['columns'][$columnName]['config']; 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. * Checks whether the given record was blacklisted by root line.
* This can be configured by typoscript as whole root lines can be black listed. * This can be configured by typoscript as whole root lines can be black listed.

View file

@ -290,6 +290,15 @@ class TcaTableService76 implements TcaTableServiceInterface
return $this->tca['columns'][$columnName]['config']; 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. * Checks whether the given record was blacklisted by root line.
* This can be configured by typoscript as whole root lines can be black listed. * This can be configured by typoscript as whole root lines can be black listed.

View file

@ -41,4 +41,6 @@ interface TcaTableServiceInterface
public function getRecords(int $offset, int $limit) : array; public function getRecords(int $offset, int $limit) : array;
public function getRecord(int $identifier) : array; public function getRecord(int $identifier) : array;
public function getLanguageUidColumn() : string;
} }

View file

@ -5,8 +5,9 @@ Changelog
:maxdepth: 1 :maxdepth: 1
:glob: :glob:
changelog/20180415-134-make-conent-fields-configurable changelog/20180410-148-keep-sys_language_uid
changelog/20180409-25-provide-sys-language-uid changelog/20180315-134-make-conent-fields-configurable
changelog/20180408-131-respect-page-cache-clear changelog/20180309-25-provide-sys-language-uid
changelog/20180408-introduce-php70-type-hints changelog/20180308-131-respect-page-cache-clear
changelog/20180406-120-facet-configuration changelog/20180308-introduce-php70-type-hints
changelog/20180306-120-facet-configuration

View file

@ -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. 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 Instead integrators are able to configure facets for search service "as is". We just pipe the

View file

@ -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. 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. We do not use PHP 7.1 Type Hints, as some customers still need PHP 7.0 support.

View file

@ -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 Previously we did not fetch ``sys_language_uid`` field from database. This prevented everyone from

View file

@ -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. Before, only ``bodytext`` was used to generate content while indexing pages.

View file

@ -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`.

View file

@ -103,11 +103,7 @@ class TcaIndexerTest extends AbstractFunctionalTestCase
->with( ->with(
$this->stringContains('tt_content'), $this->stringContains('tt_content'),
$this->callback(function ($documents) { $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;
}
}) })
); );

View file

@ -37,6 +37,59 @@ class RelationResolverTest extends AbstractUnitTestCase
$this->subject = new RelationResolver(); $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.'
);
}
/** /**
* @test * @test
*/ */