To enable more performant joins in Database implementations of new terms store when being searched against starting from specific externally linked records, we want to support passing join information instead of term ids that DatabaseTermIdsResolver can use to determine which term ids to select.
Use case was discovered in parent task. Suggested solution comes from a comment on it T225003#5256375:
// in DatabaseTermIdsResolver public function resolveGroupedTermConditions( array $groupedWhatevers ) { foreach ( $groupedWhatevers as $groupedWhatever ) { list ( $tables, $conditions ) = $groupedWhatever; $result = $db->select( array_merge( [ 'wbt_term_in_lang', 'wbt_text_in_lang', 'wbt_text' ], $tables ), [ 'wbtl_id', 'wbtl_type_id', 'wbxl_language', 'wbx_text' ], array_merge( [ 'wbtl_text_in_lang_id=wbxl_id', 'wbxl_text_id=wbx_id', ], $conditions ), __METHOD__ ); $this->preloadTypes( $result ); foreach ( $result as $row ) { foreach ( $groupNamesByTermIds[$row->wbtl_id] as $groupName ) { $this->addResultTerms( $groupedTerms[$groupName], $row ); } } return $groupedTerms; } } // in DatabasePropertyTermStore $this->resolver->resolveGroupedTermConditions( [ 'P1' => [ // extra tables [ 'wbt_property_terms' ], // extra conditions [ 'wbpt_term_in_lang_id=wbtl_id', 'wbpt_property_id' => $numericPropertyIds, ], ], ] );