When used with Organic Groups, file_entity_query_entity_field_access_alter() causes a fatal "column not found" error on certain entity field queries. In particular, this causes major problems with Open Atrium. As best I can tell, this is what's happening:

The query that causes the error starts off as something like:

SELECT field_data_og_group_ref0.entity_type AS entity_type, field_data_og_group_ref0.entity_id AS entity_id ...
FROM  {field_data_og_group_ref} field_data_og_group_ref0 ...

_file_entity_query_file_entity_access_alter() does a bunch of stuff, and ultimately adds a field_data_og_group_ref0.entity_id = fm_access.fid into the WHERE clause of a subquery.

Later, og_query_og_membership_alter() seems to be changing the table name/alias in the outer query to {og_membership} ogm, but the subquery condition stays the same, causing the Column Not Found error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JeffM2001 created an issue. See original summary.

JeffM2001’s picture

Here's a patch that prevents file_entity from altering queries that will lead to the error.

joseph.olstad’s picture

Should we act quickly on this and cut a new release of file_entity with this patch?
any objections?
Plan:
cut a new release with this patch... 2.13

timeline? less than 1 week to review from this date.

joseph.olstad’s picture

Status: Active » Needs review
joseph.olstad’s picture

joseph.olstad’s picture

This affects versions of file_entity between and including 2.0 and 2.12
If you have this issue either apply this patch OR (most likely because using organic groups), upgrade to 2.13 which will be released approximately in one or two days, expect by January 7th 2018

joseph.olstad’s picture

Status: Needs review » Fixed

Committed this patch as-is.
fixed in release 7.x-2.14
https://www.drupal.org/files/issues/file_entity-query-alter-og-2934180-2...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad
Status: Closed (fixed) » Needs review

Although appears benign

Now that #2067671: Ensure file query alteration is performed when using EntityFieldQuery
is reverted for 2.16

this commit / patch is no longer needed so review whether or not to remove this.

joseph.olstad’s picture

Should probably revert this above commit