Problem

  1. Go to group landing page,
  2. click the gear icon and select "Clone",
  3. click "Publish.

Progress bar appears and partially completes before page reloads with system error:

An error occurred.
Please continue to *the error page*...

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /openatrium/batch?id=7&op=do StatusText: Service unavailable (with message) ResponseText: OgException: OG membership for 1 - user in group 12 - node already exists. in OgMembership->save() (line 73 of C:\wamp\www\openatrium\profiles\openatrium\modules\contrib\og\includes\og.membership.inc).

When I click on *the error page* link, page loads with messages:

System message (status): "Group [group name] has been created."
System message (error): "Error cloning content".

The content has, in fact, been cloned.

Notes:

  • Attempted multiple times with same error.
  • Occurred on OA v. 7.x-2.18 (freshly installed) run on WAMPserver (Win 8)
  • Cloning content via "Create new Space", then "Create new [blueprint] Space" works fine. Progress bar appears and completes.
  • (my.conf) max_allowed_packet = 200M
  • (php.ini) memory_limit = 256M

If I can give you any more info, let me know.

Cheers -

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JKingsnorth’s picture

Version: 7.x-2.18 » 7.x-2.19

Confirmed for cloning groups in 2.19 as well, the error message is quite helpful.

It's trying to add the OG membership to the user, but the membership already exists.

The error is thrown by the OG save() function, which saves an OG membership.

I've run out of time to troubleshoot this this week but I've got as far as oa_clone_batch_clone_group_memberships() as a starting point (oa_clone.module line 596).

Perhaps oa_clone is trying to add the memberships, and then og is trying to add them again?

mpotter’s picture

Version: 7.x-2.19 » 7.x-2.23
Component: Code » oa_core

Still a problem in v2.23. Referencing internal OA-736 JIRA ticket for tracking.

mpotter’s picture

Status: Active » Closed (fixed)

Reopen if still an issue in v2.30

joep.hendrix’s picture

Status: Closed (fixed) » Active

Error still exists in openatrium-7.x-2.44

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=12&op=do StatusText: Service unavailable (with message) ResponseText: OgException: OG membership for <em class="placeholder">3</em> - <em class="placeholder">user</em> in group <em class="placeholder">18</em> - <em class="placeholder">node</em> already exists. in OgMembership->save() (line 73 of /var/www/vhosts/..../httpdocs/profiles/openatrium/modules/contrib/og/includes/og.membership.inc).

mpotter’s picture

Version: 7.x-2.23 » 7.x-2.45

Hmm, not sure why I closed this. It's still open in our JIRA queue. And it still exists in 2.45 also.

joep.hendrix’s picture

Debugging right now to find out what is going on.
Will keep you updated.

joep.hendrix’s picture

FileSize
1.67 KB

Here is the patch.
The problem is caused by the fact that the ctools page manager already has created the first membership.

joep.hendrix’s picture

Status: Active » Needs review
mpotter’s picture

See next comment

mpotter’s picture

  1. +++ b/profiles/openatrium/modules/apps/oa_clone/oa_clone.module
    @@ -890,7 +890,9 @@ function oa_clone_batch_clone_section_content($node, $original_nid, &$context) {
    -    $context['sandbox']['membership_ids'] = oa_clone_get_group_memberships($original_nid);
    +    $context['sandbox']['membership_ids'] = oa_clone_get_group_memberships(
    +      $original_nid
    +    );
         $context['sandbox']['max'] = count($context['sandbox']['membership_ids']);
    

    This is a syntax style change and should not be part of this patch. You probably need to check your IDE settings to avoid applying these kind of changes.

  2. +++ b/profiles/openatrium/modules/apps/oa_clone/oa_clone.module
    @@ -904,11 +906,14 @@ function oa_clone_batch_clone_group_memberships($node, $original_nid, &$context)
    +  // Skip the first, has already been created by ctools
    +  if ($context['sandbox']['progress'] > 0) {
    

    Can you explain more about what you are doing here? I don't understand the comment "already created by ctools".

joep.hendrix’s picture

FileSize
1.04 KB

Ah, sorry for the patched spaces, I did not notice them in the patch. Attached the correct version.

What I mean with "already created by ctools" is that the ctools module already created the first membership, thus resulting in the db error.

mpotter’s picture

Where in ctools page manager did it already create the first membership though? ctools page manager doesn't know anything about organic groups or memberships.

Also, I'm concerned that this patch is just sidestepping the base issue. Cloning spaces and other content works fine. It's just Groups that don't work. And I don't see anything here that distinguishes with the Groups, so I'm worried that this patch will break the cloning of other content.

joep.hendrix’s picture

oa_clone_node_prepopulate returns page_manager_node_edit and then the ctools magic happens ending up in ctools_context_create.

Actually, cloning a space does not create the members. I am not sure if a bug has already been issued for that.

mpotter’s picture

Cloning a space should not clone the actual user members. The only things being clones are the nodes that belong to the space (via og_membership). So not creating members is by-design.

Maybe the problem is that oa_clone_batch_clone_section_content() should not be called for Groups since Groups don't have any Sections to be cloned. For your patch, I'd probably focus on the logic in the _oa_clone_batch_space() function to see if you can find a fix that doesn't involve just always skipping the first batch like in #10.

mpotter’s picture

OK wait, ignore that.

So oa_clone_node_insert() is controlling what is done for spaces, sections, groups, etc. For Groups it *is* supposed to clone the members. But your patch in #7 was to the oa_clone_batch_clone_section_content() function, which shouldn't be called. Are you sure the problem isn't in the oa_clone_batch_clone_group_memberships() function that is cloning the actual user membership. Maybe it's trying to add the user-1 admin twice?

mpotter’s picture

OK, I must be blind. Your patch *IS* for the oa_clone_batch_clone_group_memberships() routine! Sorry, I don't know why I thought it was in the section stuff.

So I think we are close. By skipping the first batch I think you are skipping the user-1 that is a member of the space. But it's already been added since that is the *author*/owner of the group already.

So rather than just skipping the first batch, we probably need to filter the membership_ids array so it doesn't contain the owner/author of the node.

mpotter’s picture

So instead of:

if ($context['sandbox']['progress'] > 0) 

try doing

if ($next_id != $node->uid)

and see if that works?

joep.hendrix’s picture

Nope sorry, same problem...

mpotter’s picture

Status: Needs review » Needs work