mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 17:16:11 +01:00
Merge pull request #100 from Codappix/hotfix/if-record-can-not-be-updated-delete-it-instead
BUGFIX: Remove records during update if no longer available
This commit is contained in:
commit
1840eba07b
2 changed files with 33 additions and 1 deletions
|
@ -99,7 +99,8 @@ abstract class AbstractIndexer implements IndexerInterface
|
||||||
|
|
||||||
$this->connection->addDocument($this->getDocumentName(), $record);
|
$this->connection->addDocument($this->getDocumentName(), $record);
|
||||||
} catch (NoRecordFoundException $e) {
|
} catch (NoRecordFoundException $e) {
|
||||||
$this->logger->info('Could not index document.', [$e->getMessage()]);
|
$this->logger->info('Could not index document. Try to delete it therefore.', [$e->getMessage()]);
|
||||||
|
$this->connection->deleteDocument($this->getDocumentName(), $identifier);
|
||||||
}
|
}
|
||||||
$this->logger->info('Finish indexing');
|
$this->logger->info('Finish indexing');
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,4 +205,35 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
||||||
'Record was indexed with resolved category relation, but should not have any.'
|
'Record was indexed with resolved category relation, but should not have any.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function indexingDeltedRecordIfRecordShouldBeIndexedButIsNoLongerAvailableAndWasAlreadyIndexed()
|
||||||
|
{
|
||||||
|
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
|
->get(IndexerFactory::class)
|
||||||
|
->getIndexer('tt_content')
|
||||||
|
->indexAllDocuments()
|
||||||
|
;
|
||||||
|
|
||||||
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
|
$this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
|
||||||
|
|
||||||
|
$this->getConnectionPool()->getConnectionForTable('tt_content')
|
||||||
|
->update(
|
||||||
|
'tt_content',
|
||||||
|
['hidden' => true],
|
||||||
|
['uid' => 10]
|
||||||
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
|
->get(IndexerFactory::class)
|
||||||
|
->getIndexer('tt_content')
|
||||||
|
->indexDocument(10)
|
||||||
|
;
|
||||||
|
|
||||||
|
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||||
|
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document is in index.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue