If there are multiple entity types that are group, views relationship to the og group will join on incorrect data.

Example:

node are groups.
customeentity are groups.

The views relationship with gets the og_membership generates the following SQL:
LEFT JOIN og_membership ON (customeentity_og_membership.id = og_membership.gid)

Which returns both the og membership for the desired customentity, and the og membership for a node that has the same id as the custom entity.

The SQL generated should be:
LEFT JOIN og_membership ON (customeentity_og_membership.id = og_membership.gid AND og_membership.group_type = 'customeentity')

Files: 
CommentFileSizeAuthor
#8 og-views-relationship-to-group-1904622-8.patch1.9 KBspotzero
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]
#5 og-views-relationship-to-group-1904622-5.patch830 bytesspotzero
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]
#1 og-views-relationship-to-group-1904622-1.patch1.55 KBspotzero
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]

Comments

spotzero’s picture

Status:Active» Needs review
StatusFileSize
new1.55 KB
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]

The attached patch add a second og_handler_relationship class to correct the issue.

amitaibu’s picture

Thanks for the clear explanation! Isn't a declaration in the .info file missing?

spotzero’s picture

The patch added the second class to the existing og_relationship_handler.inc file, so the declaration isn't needed. If it is preferabled to include it in a seperate file, I'll update the patch and add the declaration in the .info.

Thanks,

amitaibu’s picture

Status:Needs review» Needs work

> The patch added the second class to the existing og_relationship_handler.inc file,

Nope, each handler on it's own class.

spotzero’s picture

StatusFileSize
new830 bytes
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]

Ah, the comment at the beginning of includes/views/handlers/og_handler_relationship.inc threw me off:

/**
* @file
* Contains various relationship handlers.
*/

Attached is the patch with the new relationship handler in its own file (including the .info declaration.)

spotzero’s picture

Status:Needs work» Needs review
amitaibu’s picture

Status:Needs review» Needs work

Some code seems missing form the patch...

spotzero’s picture

Status:Needs work» Needs review
StatusFileSize
new1.9 KB
PASSED: [[SimpleTest]]: [MySQL] 780 pass(es).
[ View ]

Please find the patch, with the code actually in it, attached.

Sorry for the mix up.

amitaibu’s picture

Status:Needs review» Fixed

Committed, thanks.

Status:Fixed» Closed (fixed)

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