Two different users who are each managers of groups, see their own group twice when viewing page /og as well as "My Groups" (/og/my)

The duplicate entries point to the same (correct) group; they persist for the original owners even if ownership of the group page is changed to someone else.
Non-manager users of the site see the entries properly (once).

CommentFileSizeAuthor
#1 d6:database.mysql_.inc_.patch791 byteskb_0

Comments

kb_0’s picture

StatusFileSize
new791 bytes

Can't find my original source on this patch so here is a copy. This is a patch to database.mysql.inc in d6 core that resolved your problem for us. If you use mysqli as a connector instead of mysql, you'll have to patch it instead.

tchurch’s picture

Sorry to sound dumb but I have this problem too.

What does one do with the patch?

kb_0’s picture

The patch isn't particularly complicated... Instead, just open the file ./includes/database.mysql.inc and change the lines:

    $select = preg_replace(
      '/((?:^|,)\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|$))/is',
      '\1'. $field_to_select .'\2', $matches[1], 1
    );

to:

    $select = preg_replace(
      '/((?:^|,|\()\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|\sAS|\)|$))/is',
      '\1'. $field_to_select .'\2', $matches[1], 1
    );

This resolved the problem for us.

novacore’s picture

thanks kb_0, this worked for me too!
i had to change it in /includes/database.mysqli.inc

:-D

bonobo’s picture

Haven't tested this patch, as I'm not particularly excited about patching core...

We are seeing this as well, and here is some more detail:

For the group creator (ie, the person who created the group node, and is also the manager) the view works as it should.

However, for a user who joins the group and is promoted to group admin, the problem exists (ie, groups are listed twice).

This is not an issue for UID1.

Also, for others reading this thread, hacking core is a VERY bad idea. Kittens die when you do that.

el56’s picture

Update:

I've been able to superficially eliminate the display problem within views.

I edited the view "og", subview "page":
.../admin/build/views/edit/og?destination=og#views-tab-page

Under "Basic settings" I changed "Distinct" to "Yes".
So far I haven't seen any unintended consequences, but I suspect that I'm just covering up the problem rather than fixing it.

I, too, maintain a safe fear regarding hacking core.

- Evan

bonobo’s picture

Forehead <--> Palm!

That's a great workaround --

Like you say, it doesn't actually address the underlying issue, but it does make it go away.

bonobo’s picture

Actually, setting the view to distinct did not solve this in my case.

The problem still exists.

Still not going to patch core to address this, though.

bonobo’s picture

This is likely related to #284392: db_rewrite_sql causing issues with DISTINCT.

This is also discussed at http://www.lullabot.com/blog/views-distinct-node-access-problems

We built out a small helper module that works around this. It is working for us in a specific use case, but YMMV. The download is available off the FunnyMonkey site, and is linked from this comment: http://www.lullabot.com/blog/views-distinct-node-access-problems#comment...

marcp’s picture

Like bonobo said, this is a core issue and it needs more eyes on it. There are steps to reproduce this with minimal fuss here, but I think what would be most helpful would be for people to confirm that this is a problem with PostgreSQL as well as with MySQL.

If you are a pgsql user, please help out with the core issue, which is #284392: db_rewrite_sql causing issues with DISTINCT.

moshe weitzman’s picture

Title: Group manager sees their group twice in <site>/og listing » Core bug - Group manager sees their group twice in <site>/og listing

retitle. not fixable by OG

bonobo’s picture

Status: Active » Postponed

Setting this to postponed (should this be a duplicate?) -- as this should be addressed via #284392: db_rewrite_sql causing issues with DISTINCT.

bluecafe’s picture

The solution with distinct saved my day and solved my problem. Thanks a bunch!

momo18’s picture

Groups repeated themselves twice in group directory, while using the following configuration.

Drupal 6.15
Views 6.x-3.0-alpha1
OG 6.x-2.0
panels, OG panels and more

Also using mysqli.

In core file database.mysqli.inc I changed the following line.

From:


  '/((?:^|,)\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|$))/is',

To:


	'/((?:^|,|\()\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|\sAS|\)|$))/is',

And the problem went away.

Needs fixing in core.

marcp’s picture

Status: Postponed » Closed (duplicate)

Duplicate of #284392: db_rewrite_sql causing issues with DISTINCT which is where you should provide feedback on the latest core patch.

mau-it’s picture

Subscribing.

Editing og view, as suggested in #6, was the solution for me.

Drupal 6.15 using mysql (not mysqli)
OG 6.x-2.0
Views 6.x-2.8

momo18’s picture

In organic groups, under my groups the exact same problem (refer to post #6) occurred at the destination og/my in which groups were appearing twice.

In the corresponding og_my view, selecting display type to "Page", and under "Basic settings" changing "Distinct" to "Yes" fixed it here as well.