I'm using OG field on several entity types, besides node. When we added field to custom entity type - views started to throw MySQL error.

We've found bug in `OgBehaviorHandler.class.php`file in views_data_alter method. Instead of populating $data['og_membership']['table']['join'] value with all available entity types, it adds join only for last entity type in the list.

List of entity types we have:

0 node
1 formulary
2 locator

Actual Result:

 [table] => Array (
            [join] => Array (
                    [locator] => Array (
                            [left_field] => lid
                            [field] => etid
                            [extra] => Array (
                                    [0] => Array (
                                            [field] => entity_type
                                            [value] => locator
                                        )
                                )
                        )
                )
        )

Expected result:

Array (
    [table] => Array (
            [join] => Array (
                    [node] => Array (
                            [left_field] => nid
                            [field] => etid
                            [extra] => Array (
                                    [0] => Array (
                                            [field] => entity_type
                                            [value] => node
                                        )
                                )
                        )
                    [formulary] => Array (
                            [left_field] => 
                            [field] => etid
                            [extra] => Array(
                                    [0] => Array (
                                            [field] => entity_type
                                            [value] => formulary
                                        )
                                )
                        )
                    [locator] => Array (
                            [left_field] => lid
                            [field] => etid
                            [extra] => Array (
                                    [0] => Array (
                                            [field] => entity_type
                                            [value] => locator
                                        )
                                )
                        )
                )
        )
)

Comments

x610 created an issue. See original summary.

he0x410’s picture

Patch added.

he0x410’s picture

Status: Active » Needs review
markpavlitski’s picture

We're seeing this same issue when using OG and EntityReference in Views. We're not using custom entity types though, just several together (node, users, field collections).

Here's a simplified patch which achieves the same thing.

David_Rothstein’s picture

Title: Custom entity types and EntityReference behavior in Views » OG entityreference field breaks Views when the field is attached to multiple entity types
Status: Needs review » Reviewed & tested by the community

The code looks good, and I can verify that this patch fixed the problem for me also.

jacob.embree’s picture

Assigned: he0x410 » Unassigned

This helped me too. Unassinging x610.

alesr’s picture

Issue tags: +OG-7.x-2.10-release
jacob.embree’s picture

The GitHub pull request for this issue is https://github.com/Gizra/og/pull/383.

  • alesr committed dcc92cf on 7.x-2.x authored by markpavlitski
    #2575833 OG entityreference field breaks Views when the field is...
alesr’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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