mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-25 22:56:16 +01:00
BUGFIX: Do not add non existing db columns to fields array
As TCA might contain columns which do not exist in DB, filter them out.
This commit is contained in:
parent
5509d4a56b
commit
2c466854b2
3 changed files with 66 additions and 2 deletions
|
@ -181,7 +181,10 @@ class TcaTableService
|
||||||
array_filter(
|
array_filter(
|
||||||
array_keys($this->tca['columns']),
|
array_keys($this->tca['columns']),
|
||||||
function ($columnName) {
|
function ($columnName) {
|
||||||
return !$this->isSystemField($columnName);
|
return !$this->isSystemField($columnName)
|
||||||
|
&& !$this->isUserField($columnName)
|
||||||
|
&& !$this->isPassthroughField($columnName)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -249,6 +252,18 @@ class TcaTableService
|
||||||
return in_array($columnName, $systemFields);
|
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
|
* @param string $columnName
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
@ -100,7 +100,7 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('tt_content'),
|
$this->equalTo('tt_content'),
|
||||||
$this->callback(function ($record) {
|
$this->callback(function ($record) {
|
||||||
return isset($record['uid']) && $record['uid'] === '2'
|
return isset($record['uid']) && $record['uid'] === 2
|
||||||
&& isset($record['pid']) && $record['pid'] === 1
|
&& isset($record['pid']) && $record['pid'] === 1
|
||||||
&& isset($record['header']) && $record['header'] === 'a new record'
|
&& isset($record['header']) && $record['header'] === 'a new record'
|
||||||
;
|
;
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Codappix\SearchCore\Tests\Unit\Domain\Index\TcaIndexer;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||||
|
use Codappix\SearchCore\Domain\Index\TcaIndexer\RelationResolver;
|
||||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService;
|
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService;
|
||||||
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
|
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
|
||||||
|
|
||||||
|
@ -98,4 +99,52 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
||||||
$whereClause->getParameters()
|
$whereClause->getParameters()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue