mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 09:36:11 +01:00
Merge pull request #88 from Codappix/bugfix/do-not-fetch-non-existing-db-fields
BUGFIX: Do not add non existing db columns to fields array
This commit is contained in:
commit
e321c424b4
2 changed files with 64 additions and 1 deletions
|
@ -201,7 +201,10 @@ class TcaTableService
|
|||
array_filter(
|
||||
array_keys($this->tca['columns']),
|
||||
function ($columnName) {
|
||||
return !$this->isSystemField($columnName);
|
||||
return !$this->isSystemField($columnName)
|
||||
&& !$this->isUserField($columnName)
|
||||
&& !$this->isPassthroughField($columnName)
|
||||
;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -269,6 +272,18 @@ class TcaTableService
|
|||
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';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $columnName
|
||||
* @return array
|
||||
|
|
|
@ -101,6 +101,54 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function allConfiguredAndAllowedTcaColumnsAreReturnedAsFields()
|
||||
{
|
||||
$GLOBALS['TCA']['test_table'] = [
|
||||
'ctrl' => [
|
||||
'languageField' => 'sys_language',
|
||||
],
|
||||
'columns' => [
|
||||
'sys_language' => [],
|
||||
't3ver_oid' => [],
|
||||
'available_column' => [
|
||||
'config' => [
|
||||
'type' => 'input',
|
||||
],
|
||||
],
|
||||
'user_column' => [
|
||||
'config' => [
|
||||
'type' => 'user',
|
||||
],
|
||||
],
|
||||
'passthrough_column' => [
|
||||
'config' => [
|
||||
'type' => 'passthrough',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$subject = new TcaTableService(
|
||||
'test_table',
|
||||
$this->getMockBuilder(RelationResolver::class)->getMock(),
|
||||
$this->configuration
|
||||
);
|
||||
$this->inject($subject, 'logger', $this->getMockedLogger());
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
'test_table.uid',
|
||||
'test_table.pid',
|
||||
'test_table.available_column',
|
||||
],
|
||||
$subject->getFields(),
|
||||
''
|
||||
);
|
||||
unset($GLOBALS['TCA']['test_table']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue