mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-24 07:36:10 +01:00
Merge remote-tracking branch 'origin/develop' into feature/support-typo3-7-to-8
Conflicts: Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php
This commit is contained in:
commit
835924a8d8
10 changed files with 221 additions and 36 deletions
|
@ -250,7 +250,6 @@ class TcaTableService implements TcaTableServiceInterface
|
||||||
$this->tca['ctrl']['cruser_id'],
|
$this->tca['ctrl']['cruser_id'],
|
||||||
$this->tca['ctrl']['fe_cruser_id'],
|
$this->tca['ctrl']['fe_cruser_id'],
|
||||||
$this->tca['ctrl']['fe_crgroup_id'],
|
$this->tca['ctrl']['fe_crgroup_id'],
|
||||||
$this->tca['ctrl']['languageField'],
|
|
||||||
$this->tca['ctrl']['origUid'],
|
$this->tca['ctrl']['origUid'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,24 @@ class DataHandler implements Singleton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearCachePostProc(array $parameters, CoreDataHandler $dataHandler)
|
||||||
|
{
|
||||||
|
$pageUid = 0;
|
||||||
|
|
||||||
|
// If editor uses "small page blizzard"
|
||||||
|
if (isset($parameters['cacheCmd']) && is_numeric($parameters['cacheCmd'])) {
|
||||||
|
$pageUid = $parameters['cacheCmd'];
|
||||||
|
}
|
||||||
|
// If records were changed
|
||||||
|
if (isset($parameters['uid_page']) && is_numeric($parameters['uid_page'])) {
|
||||||
|
$pageUid = $parameters['uid_page'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pageUid > 0) {
|
||||||
|
$this->processRecord('pages', (int) $pageUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function processRecord(string $table, int $uid) : bool
|
protected function processRecord(string $table, int $uid) : bool
|
||||||
{
|
{
|
||||||
if (! $this->shouldProcessHookForTable($table)) {
|
if (! $this->shouldProcessHookForTable($table)) {
|
||||||
|
|
|
@ -5,5 +5,7 @@ Changelog
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
:glob:
|
:glob:
|
||||||
|
|
||||||
|
changelog/20180409-25-provide-sys-language-uid
|
||||||
|
changelog/20180408-131-respect-page-cache-clear
|
||||||
changelog/20180408-introduce-php70-type-hints
|
changelog/20180408-introduce-php70-type-hints
|
||||||
changelog/20180406-120-facet-configuration
|
changelog/20180406-120-facet-configuration
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
Feature 131 "Pages do not get indexed if content has changed"
|
||||||
|
=============================================================
|
||||||
|
|
||||||
|
Previously we only used DataHandler hooks triggered when processing records. This way we did not
|
||||||
|
index a page when content has changed.
|
||||||
|
|
||||||
|
We now also use cache clear hooks of DataHandler to index pages whenever their cache get cleared.
|
||||||
|
This way we also index a page if an integrator configured to clear further pages if content was
|
||||||
|
changed.
|
||||||
|
|
||||||
|
Still there are limitations. We do not get informed for pages which got cleared due to attached
|
||||||
|
caches via TypoScript.
|
||||||
|
|
||||||
|
See :issue:`131`.
|
|
@ -0,0 +1,16 @@
|
||||||
|
FEATURE 25 "Respect multiple languages" - Provide sys_language_uid
|
||||||
|
==================================================================
|
||||||
|
|
||||||
|
Previously we did not fetch ``sys_language_uid`` field from database. This prevented everyone from
|
||||||
|
working with multiple languages.
|
||||||
|
By not removing the field it gets indexed and provides a very basic way of implementing multiple
|
||||||
|
languages.
|
||||||
|
At least it's now possible to filter search results by current language for now. Still the records
|
||||||
|
are not "valid" as we do not add overlays for now.
|
||||||
|
|
||||||
|
This is a first step into full multi language support.
|
||||||
|
|
||||||
|
Martin Hummer already has a basic proof of concept, based on :ref:`concepts_dataprocessing` working,
|
||||||
|
depending on ``sys_language_uid``.
|
||||||
|
|
||||||
|
See :issue:`25`.
|
|
@ -47,7 +47,11 @@ class NonAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
*/
|
*/
|
||||||
public function deletionWillNotBeTriggeredForSysCategories()
|
public function deletionWillNotBeTriggeredForSysCategories()
|
||||||
{
|
{
|
||||||
$this->subject->expects($this->exactly(0))->method('delete');
|
$this->subject->expects($this->exactly(1))
|
||||||
|
->method('update')
|
||||||
|
->with('pages', $this->callback(function (array $record) {
|
||||||
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
|
}));
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
$tce->stripslashes_values = 0;
|
$tce->stripslashes_values = 0;
|
||||||
|
@ -66,7 +70,11 @@ class NonAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
*/
|
*/
|
||||||
public function updateWillNotBeTriggeredForExistingSysCategory()
|
public function updateWillNotBeTriggeredForExistingSysCategory()
|
||||||
{
|
{
|
||||||
$this->subject->expects($this->exactly(0))->method('update');
|
$this->subject->expects($this->exactly(1))
|
||||||
|
->method('update')
|
||||||
|
->with('pages', $this->callback(function (array $record) {
|
||||||
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
|
}));
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
$tce->stripslashes_values = 0;
|
$tce->stripslashes_values = 0;
|
||||||
|
@ -85,7 +93,11 @@ class NonAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
*/
|
*/
|
||||||
public function updateWillNotBeTriggeredForNewSysCategoy()
|
public function updateWillNotBeTriggeredForNewSysCategoy()
|
||||||
{
|
{
|
||||||
$this->subject->expects($this->exactly(0))->method('update');
|
$this->subject->expects($this->exactly(1))
|
||||||
|
->method('update')
|
||||||
|
->with('pages', $this->callback(function (array $record) {
|
||||||
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
|
}));
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
$tce->stripslashes_values = 0;
|
$tce->stripslashes_values = 0;
|
||||||
|
|
|
@ -50,6 +50,11 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
$this->subject->expects($this->exactly(1))
|
$this->subject->expects($this->exactly(1))
|
||||||
->method('delete')
|
->method('delete')
|
||||||
->with($this->equalTo('tt_content'), $this->equalTo('1'));
|
->with($this->equalTo('tt_content'), $this->equalTo('1'));
|
||||||
|
$this->subject->expects($this->exactly(1))
|
||||||
|
->method('update')
|
||||||
|
->with('pages', $this->callback(function (array $record) {
|
||||||
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
|
}));
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
$tce->stripslashes_values = 0;
|
$tce->stripslashes_values = 0;
|
||||||
|
@ -68,23 +73,32 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
*/
|
*/
|
||||||
public function updateWillBeTriggeredForExistingTtContent()
|
public function updateWillBeTriggeredForExistingTtContent()
|
||||||
{
|
{
|
||||||
$this->subject->expects($this->exactly(1))->method('update')
|
<<<<<<< HEAD
|
||||||
->with(
|
$this->subject->expects($this->exactly(2))->method('update')
|
||||||
$this->equalTo('tt_content'),
|
->withConsecutive(
|
||||||
$this->callback(function ($record) {
|
[
|
||||||
if ($this->isLegacyVersion()) {
|
$this->equalTo('tt_content'),
|
||||||
return isset($record['uid']) && $record['uid'] === '1'
|
$this->callback(function ($record) {
|
||||||
&& isset($record['pid']) && $record['pid'] === '1'
|
if ($this->isLegacyVersion()) {
|
||||||
&& isset($record['colPos']) && $record['colPos'] === '1'
|
return isset($record['uid']) && $record['uid'] === '1'
|
||||||
;
|
&& isset($record['pid']) && $record['pid'] === '1'
|
||||||
}
|
&& isset($record['colPos']) && $record['colPos'] === '1'
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
return isset($record['uid']) && $record['uid'] === 1
|
return isset($record['uid']) && $record['uid'] === 1
|
||||||
&& isset($record['pid']) && $record['pid'] === 1
|
&& isset($record['pid']) && $record['pid'] === 1
|
||||||
&& isset($record['colPos']) && $record['colPos'] === 1
|
&& isset($record['colPos']) && $record['colPos'] === 1
|
||||||
;
|
;
|
||||||
})
|
})
|
||||||
);
|
],
|
||||||
|
[
|
||||||
|
$this->equalTo('pages'),
|
||||||
|
$this->callback(function ($record) {
|
||||||
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
$tce->stripslashes_values = 0;
|
$tce->stripslashes_values = 0;
|
||||||
|
@ -103,22 +117,30 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest
|
||||||
*/
|
*/
|
||||||
public function updateWillBeTriggeredForNewTtContent()
|
public function updateWillBeTriggeredForNewTtContent()
|
||||||
{
|
{
|
||||||
$this->subject->expects($this->exactly(1))->method('update')
|
$this->subject->expects($this->exactly(2))->method('update')
|
||||||
->with(
|
->withConsecutive(
|
||||||
$this->equalTo('tt_content'),
|
[
|
||||||
$this->callback(function ($record) {
|
$this->equalTo('tt_content'),
|
||||||
if ($this->isLegacyVersion()) {
|
$this->callback(function ($record) {
|
||||||
return isset($record['uid']) && $record['uid'] === '2'
|
if ($this->isLegacyVersion()) {
|
||||||
&& isset($record['pid']) && $record['pid'] === '1'
|
return isset($record['uid']) && $record['uid'] === '2'
|
||||||
|
&& isset($record['pid']) && $record['pid'] === '1'
|
||||||
|
&& isset($record['header']) && $record['header'] === 'a new record'
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($record['uid']) && $record['uid'] === 2
|
||||||
|
&& isset($record['pid']) && $record['pid'] === 1
|
||||||
&& isset($record['header']) && $record['header'] === 'a new record'
|
&& isset($record['header']) && $record['header'] === 'a new record'
|
||||||
;
|
;
|
||||||
}
|
})
|
||||||
|
],
|
||||||
return isset($record['uid']) && $record['uid'] === 2
|
[
|
||||||
&& isset($record['pid']) && $record['pid'] === 1
|
$this->equalTo('pages'),
|
||||||
&& isset($record['header']) && $record['header'] === 'a new record'
|
$this->callback(function ($record) {
|
||||||
;
|
return isset($record['uid']) && $record['uid'] === 1;
|
||||||
})
|
})
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
$tce = GeneralUtility::makeInstance(Typo3DataHandler::class);
|
||||||
|
|
|
@ -128,10 +128,14 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
||||||
{
|
{
|
||||||
$GLOBALS['TCA']['test_table'] = [
|
$GLOBALS['TCA']['test_table'] = [
|
||||||
'ctrl' => [
|
'ctrl' => [
|
||||||
'languageField' => 'sys_language',
|
'languageField' => 'sys_language_uid',
|
||||||
],
|
],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
'sys_language' => [],
|
'sys_language_uid' => [
|
||||||
|
'config' => [
|
||||||
|
'type' => 'select',
|
||||||
|
],
|
||||||
|
],
|
||||||
't3ver_oid' => [],
|
't3ver_oid' => [],
|
||||||
'available_column' => [
|
'available_column' => [
|
||||||
'config' => [
|
'config' => [
|
||||||
|
@ -161,6 +165,7 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
||||||
// [
|
// [
|
||||||
// 'test_table.uid',
|
// 'test_table.uid',
|
||||||
// 'test_table.pid',
|
// 'test_table.pid',
|
||||||
|
// 'test_table.sys_language_uid',
|
||||||
// 'test_table.available_column',
|
// 'test_table.available_column',
|
||||||
// ],
|
// ],
|
||||||
// $subject->getFields(),
|
// $subject->getFields(),
|
||||||
|
|
94
Tests/Unit/Hook/DataHandlerTest.php
Normal file
94
Tests/Unit/Hook/DataHandlerTest.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
namespace Codappix\SearchCore\Tests\Unit\Hook;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* 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\Service\DataHandler as OwnDataHandler;
|
||||||
|
use Codappix\SearchCore\Hook\DataHandler;
|
||||||
|
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
|
||||||
|
use TYPO3\CMS\Core\DataHandling\DataHandler as CoreDataHandler;
|
||||||
|
|
||||||
|
class DataHandlerToProcessorTest extends AbstractUnitTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @dataProvider getPossibleCallCombinations
|
||||||
|
*/
|
||||||
|
public function fieldsAreCopiedAsConfigured(array $parameters, bool $expectCall)
|
||||||
|
{
|
||||||
|
$coreDataHandlerMock = $this->getMockBuilder(CoreDataHandler::class)->getMock();
|
||||||
|
$ownDataHandlerMock = $this->getMockBuilder(OwnDataHandler::class)
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$subject = $this->getMockBuilder(DataHandler::class)
|
||||||
|
->setConstructorArgs([$ownDataHandlerMock])
|
||||||
|
->setMethods(['getRecord'])
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$ownDataHandlerMock->expects($this->any())
|
||||||
|
->method('supportsTable')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
|
if ($expectCall) {
|
||||||
|
$subject->expects($this->once())
|
||||||
|
->method('getRecord')
|
||||||
|
->with('pages', 10)
|
||||||
|
->willReturn(['uid' => 10]);
|
||||||
|
$ownDataHandlerMock->expects($this->once())
|
||||||
|
->method('update')
|
||||||
|
->with('pages', ['uid' => 10]);
|
||||||
|
} else {
|
||||||
|
$subject->expects($this->never())
|
||||||
|
->method('getRecord');
|
||||||
|
$ownDataHandlerMock->expects($this->never())
|
||||||
|
->method('update');
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject->clearCachePostProc($parameters, $coreDataHandlerMock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPossibleCallCombinations() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Editor triggered cache clear of page manual' => [
|
||||||
|
'parameters' => [
|
||||||
|
'cacheCmd' => '10',
|
||||||
|
],
|
||||||
|
'expectCall' => true,
|
||||||
|
],
|
||||||
|
'Editor changed records on a page' => [
|
||||||
|
'parameters' => [
|
||||||
|
'uid_page' =>10,
|
||||||
|
],
|
||||||
|
'expectCall' => true,
|
||||||
|
],
|
||||||
|
'Something unexpected' => [
|
||||||
|
'parameters' => [],
|
||||||
|
'expectCall' => false,
|
||||||
|
],
|
||||||
|
'Something unexpected' => [
|
||||||
|
'parameters' => [
|
||||||
|
'cacheCmd' => 'something like a tag?!',
|
||||||
|
],
|
||||||
|
'expectCall' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,9 @@ call_user_func(
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
't3lib/class.t3lib_tcemain.php' => [
|
't3lib/class.t3lib_tcemain.php' => [
|
||||||
|
'clearCachePostProc' => [
|
||||||
|
$extensionKey => \Codappix\SearchCore\Hook\DataHandler::class . '->clearCachePostProc',
|
||||||
|
],
|
||||||
'processCmdmapClass' => [
|
'processCmdmapClass' => [
|
||||||
$extensionKey => \Codappix\SearchCore\Hook\DataHandler::class,
|
$extensionKey => \Codappix\SearchCore\Hook\DataHandler::class,
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue