ext-solr
ext-solr copied to clipboard
[BUG] In a nested SOLR_RELATION the wrong relation items get indexed
Describe the bug
In a nested relation where the 2nd level relation is an n:m relation the wrong items get indexed when using cObject SOLR_RELATION
. As far as I can see this is because when resolving the recursive relation the value from the local field is taken as uid list, but in case of an n:m relation this value contains only the number of relations.
The related code is in class ApacheSolrForTypo3\Solr\ContentObject\Relation
in method getRelatedItemsFromForeignTable
:
$itemList = $parentContentObject->data[$this->configuration['localField']] ?? '';
$relationHandler->start($itemList, $foreignTableName, '', $localRecordUid, $localTableName, $localFieldTca['config']);
$selectUids = $relationHandler->tableArray[$foreignTableName];
To Reproduce Steps to reproduce the behavior:
- Create a table A with an 1:m relation to table B
- In table B create an n:m relation to table C
- Configure indexing for table A with a multi value field that should contain all relations to table C
- Index the records
- Look up the indexed values in Solr and see they are wrong
Expected behavior When indexing nested n:m relations the related values should be resolved correctly.
Used versions (please complete the following information):
- TYPO3 Version: 11.5.4
- EXT:solr Version: dev-release-11.5.x
- Used Apache Solr Version: 8.11.1
- PHP Version: 8.0.13
- MariaDB Version: 10.5.13
I have seen #2147 describing a similar case but it doesn't fix the issue for me. #2743 is similar too but without n:m relation.
Possible solution could be to also take the TCA setting 'MM' in method getRelatedItemsFromForeignTable
into account like:
$itemList = $parentContentObject->data[$this->configuration['localField']] ?? '';
$mmTableName = $localFieldTca['config']['MM'] ?? '';
$relationHandler->start($itemList, $foreignTableName, $mmTableName, $localRecordUid, $localTableName, $localFieldTca['config']);
I tried this in my scenario and it fixed the issue for me.
I confirm the bug but the suggested solution did not fix this for me. In my case the first object relation is a 1:m and the 2nd is a n:m relation.
@dkd-friedrich Please port this in 11.5.x
Fixed with https://github.com/TYPO3-Solr/ext-solr/pull/3484 and https://github.com/TYPO3-Solr/ext-solr/pull/3475