[Bug] Changes the indexing_configuration for the queue to the same name (value)
I have three different indexConfig entries for the same table.
plugin.tx_solr.index.queue {
test1 = 1
test1 {
table = tx_test_domain_model_entry
additionalWhereClause = uid = 1
fields {
title = original_title
title_textEdgeNgramS = original_title
}
}
test2 = 1
test2 {
initialization = Cc\Test\IndexQueue\Initializer\Test2Plugin
indexer = Cc\Test\IndexQueue\Test2SolrIndexer
table = tx_test_domain_model_entry
}
test3 = 1
test3 {
initialization = Cc\Test\IndexQueue\Initializer\Test3Plugin
indexer = Cc\Test\IndexQueue\Test3SolrIndexer
table = tx_test_domain_model_entry
}
}
Now I put the three indexConfigs on the index queue in the TYPO3 backend. The result in the table tx_solr_indexqueue_item for entry with UID 1 is.
uid root item_type item_uid indexing_configuration has_indexing_properties indexing_priority changed indexed errors pages_mountidentifier
59670 2 tx_test_domain_model_entry 1 test1 0 0 1578412622 0
59671 2 tx_test_domain_model_entry 1 test2 0 0 1578412622 0
61718 2 tx_test_domain_model_entry 1 test3 0 0 1578413861 0
So far everything looks good. Now you update the entry with UID 1 in the TYPO3 backend. Then all entries in the table tx_solr_indexqueue_item have the same indexing_configuration value with the name "test1". This means that only one entry in the Solr is updated with the indexConfig "test1", but the entries for "test2" and "test3" are no longer updated, since they are no longer in the queue.
The result in the table tx_solr_indexqueue_item for entry with UID 1 is now.
uid root item_type item_uid indexing_configuration has_indexing_properties indexing_priority changed indexed errors pages_mountidentifier
59670 2 tx_test_domain_model_entry 1 test1 0 0 1578412622 0
59671 2 tx_test_domain_model_entry 1 test1 0 0 1578412622 0
61718 2 tx_test_domain_model_entry 1 test1 0 0 1578413861 0
The cause seems to be in the function \ApacheSolrForTypo3\Solr\Domain\Index\Queue\QueueItemRepository::updateExistingItemByItemTypeAndItemUidAndRootPageId, because here the indexing_configuration is strangely always overwritten.
public function updateExistingItemByItemTypeAndItemUidAndRootPageId(string $itemType, int $itemUid, int $rootPageId, int $changedTime, string $indexingConfiguration = '') : int
{
$queryBuilder = $this->getQueryBuilder();
$queryBuilder
->update($this->table)
->set('changed', $changedTime)
->andWhere(
$queryBuilder->expr()->eq('item_type', $queryBuilder->createNamedParameter($itemType)),
$queryBuilder->expr()->eq('item_uid', $itemUid),
$queryBuilder->expr()->eq('root', $rootPageId)
);
# Why?
if (!empty($indexingConfiguration)) {
$queryBuilder->set('indexing_configuration', $indexingConfiguration);
}
return $queryBuilder->execute();
}
Used versions:
TYPO3 Version: 9.5.13 EXT:solr Version: 10.0.1 Used Apache Solr Version: 8.2.0 PHP Version: 7.2.21
The if() is completely bogus. The configuration should not be set but queried for.
if (!empty($indexingConfiguration)) {
$queryBuilder->$queryBuilder->expr()->eq('indexing_configuration', $queryBuilder->createNamedParameter($indexingConfiguration)),
}
Though I wonder why $indexingConfiguration should ever be empty.
Looking at the code of 13.0.3 it will always be set which is a good thing.