diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
index 7124ca1..3f0d39b 100644
--- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
+++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
@@ -79,8 +79,14 @@ class PagesIndexer extends TcaIndexer
protected function fetchContentForPage(int $uid) : array
{
if ($this->contentTableService instanceof TcaTableService) {
- $contentElements = $this->contentTableService->getQuery()
- ->execute()->fetchAll();
+ $queryBuilder = $this->contentTableService->getQuery();
+ $queryBuilder->andWhere(
+ $queryBuilder->expr()->eq(
+ $this->contentTableService->getTableName() . '.pid',
+ $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
+ )
+ );
+ $contentElements = $queryBuilder->execute()->fetchAll();
} else {
$contentElements = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
$this->contentTableService->getFields(),
diff --git a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
index e9eab37..ae671dd 100644
--- a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
+++ b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
@@ -49,12 +49,11 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
- $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
- $this->assertArraySubset(
- ['_source' => ['header' => 'indexed content element']],
- $response->getData()['hits']['hits'][1],
- false,
+ $this->assertTrue($response->isOk(), 'Elastica did not answer with ok code.');
+ $this->assertSame($response->getData()['hits']['total'], 3, 'Not exactly 3 documents were indexed.');
+ $this->assertSame(
+ 'indexed content element',
+ $response->getData()['hits']['hits'][2]['_source']['header'],
'Record was not indexed.'
);
}
@@ -72,7 +71,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
+ $this->assertTrue($response->isOk(), 'Elastica did not answer with ok code.');
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
$this->assertArraySubset(
['_source' => ['header' => 'indexed content element']],
@@ -112,8 +111,8 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
- $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
+ $this->assertTrue($response->isOk(), 'Elastica did not answer with ok code.');
+ $this->assertSame($response->getData()['hits']['total'], 3, 'Not exactly 3 documents were indexed.');
}
/**
@@ -135,8 +134,8 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
- $this->assertSame($response->getData()['hits']['total'], 3, 'Not exactly 3 documents were indexed.');
+ $this->assertTrue($response->isOk(), 'Elastica did not answer with ok code.');
+ $this->assertSame($response->getData()['hits']['total'], 4, 'Not exactly 4 documents were indexed.');
$response = $this->client->request('typo3content/_search?q=uid:11');
$this->assertArraySubset(
['_source' => ['header' => 'Also indexable record']],
@@ -167,8 +166,8 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
;
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
- $this->assertSame($response->getData()['hits']['total'], 4, 'Not exactly 4 documents were indexed.');
+ $this->assertTrue($response->isOk(), 'Elastica did not answer with ok code.');
+ $this->assertSame($response->getData()['hits']['total'], 5, 'Not exactly 5 documents were indexed.');
$response = $this->client->request('typo3content/_search?q=uid:11');
$this->assertArraySubset(
@@ -209,7 +208,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
/**
* @test
*/
- public function indexingDeltedRecordIfRecordShouldBeIndexedButIsNoLongerAvailableAndWasAlreadyIndexed()
+ public function indexingDeletedRecordIfRecordShouldBeIndexedButIsNoLongerAvailableAndWasAlreadyIndexed()
{
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
->get(IndexerFactory::class)
@@ -218,7 +217,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
;
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
+ $this->assertSame($response->getData()['hits']['total'], 3, 'Not exactly 3 documents were indexed.');
if ($this->isLegacyVersion()) {
$this->getDatabaseConnection()
@@ -239,6 +238,6 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
;
$response = $this->client->request('typo3content/_search?q=*:*');
- $this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document is in index.');
+ $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 document is in index.');
}
}
diff --git a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
index c236f07..409e46c 100644
--- a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
+++ b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
@@ -99,4 +99,31 @@
0
0
+
+
+ 100
+ 2
+ 1480686370
+ 1480686370
+ 0
+ 72
+ header
+
+ This element is on a different page
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 2
+ 1
+ Second page with content
+ Used to check whether content is indexed only for parent page.
+
diff --git a/Tests/Functional/Indexing/PagesIndexerTest.php b/Tests/Functional/Indexing/PagesIndexerTest.php
index 244413d..bc26dfd 100644
--- a/Tests/Functional/Indexing/PagesIndexerTest.php
+++ b/Tests/Functional/Indexing/PagesIndexerTest.php
@@ -48,7 +48,7 @@ class PagesIndexerTest extends AbstractFunctionalTestCase
->with(
$this->stringContains($tableName),
$this->callback(function ($documents) {
- return count($documents) === 1
+ return count($documents) === 2
&& isset($documents[0]['content']) && $documents[0]['content'] ===
'this is the content of header content element that should get indexed Some text in paragraph'
&& isset($documents[0]['search_abstract']) && $documents[0]['search_abstract'] ===