Skip to content
Snippets Groups Projects

Issue #3493035 attach the correct terms to posts.

1 file
+ 13
6
Compare changes
  • Side-by-side
  • Inline
@@ -130,12 +130,19 @@ class Posts extends SqlBase {
@@ -130,12 +130,19 @@ class Posts extends SqlBase {
*/
*/
protected function getTaxonomyTerms(Row $row, string $taxonomy) {
protected function getTaxonomyTerms(Row $row, string $taxonomy) {
$query = $this->select('term_relationships', 'tr')
$query = $this->select('term_relationships', 'tr')
->fields('tr', ['term_taxonomy_id']);
->fields('t', ['term_id', 'name']);
$query->join(
$query->join('term_taxonomy', 'tt', 'tr.term_taxonomy_id = tt.term_taxonomy_id and tt.taxonomy = :tag_taxonomy', [
'term_taxonomy',
':tag_taxonomy' => $taxonomy,
'tt',
]);
'tr.term_taxonomy_id = tt.term_taxonomy_id'
$query->condition('object_id', $row->get('id'));
);
 
$query->join(
 
'terms',
 
't',
 
'tt.term_id = t.term_id'
 
);
 
$query->condition('tt.taxonomy', $taxonomy)
 
->condition('tr.object_id', $row->get('id'));
return array_values($query->execute()->fetchAllKeyed(0, 0));
return array_values($query->execute()->fetchAllKeyed(0, 0));
}
}
Loading