TYPO3-Solr / ext-solr

A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
GNU General Public License v3.0
137 stars 250 forks source link

Relation does not take foreign match fields into account #520

Open dkd-friedrich opened 8 years ago

dkd-friedrich commented 8 years ago

Bart Lammers wrote:

When using 'relation' in the Solr indexing configuration, this relation does not take the foreign_match_field into account.

I found this when trying to index file references between News and FAL (fal_media) field. The sys_file_reference table is used for a multitude of references between various tables, and all that match the local and foreign id's in this case, are retreived.

(Not quite optimised) solution could be:

Classes/ContentObject/Relation.php : around line 165

if (!empty($localFieldTca['config']['foreign_match_fields'])) {
    $foreignMatchFields = $localFieldTca['config']['foreign_match_fields'];
    foreach ($foreignMatchFields as $foreignMatchField => $foreignMatchValue) {
        $whereClause .= ' AND (' . $foreignTableName . '.' . $foreignMatchField . ' = "' . $foreignMatchValue . '")';
    }
}

https://forge.typo3.org/issues/66050

Since sys_file_reference stores relations to several tables and fields I think that "foreign_match_fields" and "foreign_table_field" have to be considered.

dkd-friedrich commented 8 years ago

Estimation:

Effort: 13 Value: 13