Wrong join condition for EntityFieldQuery

Created on 24 February 2020, over 5 years ago
Updated 19 August 2025, 6 days ago

Hi.

When using flag 7.x-3.x, entityfieldquery can used for property and field query.
But, If you attach entityCondition for bundle filtering, It may return wrong results or empty.

Because, flag_query_flagging_flag_names_alter function attach joins to query for bundle condition.
But, It uses wrong column for joining.

function flag_query_flagging_flag_names_alter(QueryAlterableInterface $query) {
  ...
  if (!isset($tables['flagging'])) {
    // All tables that are in the query will be field tables and are equivalent,
    // so just join on the first one.
    $field_table = reset($tables);
    $field_table_alias = $field_table['alias'];

    $query->join('flagging', 'flagging', "$field_table_alias.entity_id = flagging.fid");
  }

  ...
}

This code join tables with flagging as fid and entity_id. But it's not id of flagging entity.
we should join with flagging_id of flagging table. It an entity_id of flagging entity.

🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Flag core

Created by

🇰🇷South Korea barami

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024