Hi,

There seems to be a major bug with the OG - Regcode - Rules setup. I have tried all combinations with the stable and dev branches where applicable on a vanilla 7.28.

When I hit the "Add Rule' link via Regcode Admin, I get a WSOD. On the log, I get the following

[Tue Jun 03 00:40:32 2014] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function og_label() in /var/www/xxxxxx/sites/all/modules/regcode/regcode_og/regcode_og.module on line 164, referer: http://127.0.0.1/xxxxxx/admin/config/people/regcode/og

I built a Rule via Rules and tried testing it out. The error code I got was

  Warning: Missing argument 3 for regcode_og_regcode_used(), called in /var/www/xxxxxx/sites/all/modules/regcode/regcode.module on line 442 and defined in regcode_og_regcode_used() (line 289 of /var/www/xxxxxx/sites/all/modules/regcode/regcode_og/regcode_og.module).
Notice: Undefined variable: regcode in regcode_og_regcode_used() (line 291 of /var/www/xxxxxx/sites/all/modules/regcode/regcode_og/regcode_og.module).
Recoverable fatal error: Argument 2 passed to og_rules_add_entity_to_group() must be an instance of EntityDrupalWrapper, instance of EntityListWrapper given in og_rules_add_entity_to_group() (line 353 of /var/www/xxxxxx/sites/all/modules/og/og.rules.inc).

I'm guessing something is critically broken, not sure where. Anyone help?

Thanks

K

Comments

jmatuska’s picture

I am having the same problem.

- Drupal core 7.28
- Organic groups version 7.x-2.7
- am currently using this dev version of Registration codes (7.x-1.1+9-dev), but first tried the stable release (7.x-1.1) and got this same error.

When i go into Configuration > People > Registration codes and go to the 7th/last tab (Organic Groups) and click on "Add rule", I get this error:
Fatal error: Call to undefined function og_label() in /home/content/94/7074694/html/dr/sites/all/modules/regcode/regcode_og/regcode_og.module on line 164

Lauren Kelly’s picture

Based on the patch provided here https://www.drupal.org/node/1491140 I made a patch for regcode_og that is working for me on my site running D7.28 with OG 7.x-2.7

Lauren Kelly’s picture

Based on the patch provided here https://www.drupal.org/node/1491140 I made a patch for regcode_og that is working for me on my site running D7.28 with OG 7.x-2.7

jmatuska’s picture

thanks Lauren. i applied your patch.
I can create a new rule, but now i'm getting these errors at the top of the registration codes > OG tab page:

Notice: Undefined variable: gid in regcode_og_rules_page() (line 255 of /home/content/94/7074694/html/dr/sites/all/modules/regcode/regcode_og/regcode_og.module).
Notice: Trying to get property of non-object in regcode_og_rules_page() (line 256 of /home/content/94/7074694/html/dr/sites/all/modules/regcode/regcode_og/regcode_og.module).
Notice: Trying to get property of non-object in regcode_og_rules_page() (line 263 of /home/content/94/7074694/html/dr/sites/all/modules/regcode/regcode_og/regcode_og.module).

Lauren Kelly’s picture

I was just testing further and came across more issues....

This is an updated patch that got me through to creating users as a member of the appropriate group - but it will only work if the group is a node.

I had to add a group_type argument at line 305 - and ours in a node...so....

If someone knows a better way to grab the group_type, that should probably be implemented here.

Offlein’s picture

Hi, this works. The patch should be "-p1 style", however, and made from the root of the project directory (as opposed to your docroot). Also you had an extra space. Reuploaded.

Offlein’s picture

I guess I could attach the file too. ...I guess.

Offlein’s picture

Priority: Normal » Critical
Status: Active » Needs review

Also this is critical. We should get this in ASAP.

scottalan’s picture

StatusFileSize
new2.61 KB

As of og-7.x-2.x the og_label method is deprecated in favor of just using entity_label(). This patch should handle both og-7.x-1.x and og-7.x-2.x considering entity_label() is available in core.

This also handles a warning when a "tag" hasn't been defined for a rule.

As far as the drupal_alter() is concerned, I ran into this issue using Open Atrium as it allows you to create multiple groups with sub-groups. This of course can apply to OG outside of OA depending on your setup.

Example use of the alter:

function [MODULE]_regcode_og_label_alter(&$labels, $entity) {
  if (!empty($entity->{OA_PARENT_SPACE})) {
    $target_id = $entity->{OA_PARENT_SPACE}[LANGUAGE_NONE][0]['target_id'];
    $node = node_load($target_id);
    $labels[$entity->nid] = $labels[$entity->nid] . ' ' . '[' . $node->title . ']';
  }
}
niallmurphy-ie’s picture

Thanks everyone! #7 works for me.. Fixes the Add Rule WSOD and allows registration. #9 fixes the Add Rule WSOD but gives a WSOD (if memory serves me right) when a voucher is used for OG.

7.x-1.1 + OG 7.x-2.7

held69’s picture

Applied patch under #9

Getting:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 437189 bytes) in C:\wamp\www\dev\includes\database\database.inc on line 2168

@ayesh Thanks! have raised my php limit.

Upon clicking the link 'add rule' the page doesn't lead to another page.
Instead it keeps searching...

ayesh’s picture

Guys I became the maintainer of the module just a few weeks ago, and I'm working on a 2.0 version to make the module more object oriented and inherit a lot of features from Entity API.
From what I can see, this module depends on OG 1.0 version (in both 6.x and 7.x), which has the ob_label function. As of now, we need a rewrite or at least a serious work. #9 seems to fix the missing function issue.

Re #9: try increasing your site's memory limit. This patch adds an extra function to load og group labels, which I believe takes some more memory. But it's not a problem with the new function itself.

I will work on this.

held69’s picture

I have tons of groups so it took a while to load them all.

However i havent been able to get the organic group part working.

I have set up a rule by selecting a group.

Then created a code and logged in with a new user using the code.
The logged in user didn't get to his group.
Maybe i am missing something.

I used the simpler module:https://www.drupal.org/node/2023099

which worked straight of the box

After the login of the new user the user is taken to his group selected in the rule.

niallmurphy-ie’s picture

If you only want set codes per group (instead of many vouchers), you can get most of the functionality of this using rules and entity forms..

I allow users to create a group and set the code / codes fields using entity forms rules.
Then, have another entity form or user field that uses a rule to "fetch by property" when a code is entered. This finds the group in the rule and allows you to subscribe, set roles, redirect etc.

held69’s picture

Thanks for your reply.
I am not that familiar with entity forms.
As my use case is pretty straightforward i was hoping to get
my solution out of the box.

Usecase:
Administrator (user 1) picks a group where users should be subscribed to after login.
Administrator creates about 50-100 codes.

Users receive codes by post.
Users use registercode to login.
After login user is taken to his group.

As mentioned i have only got this to work with the simple version of this module.
The bulk function however when enabled prevents the function from working correct.

Could rules be an option in my case?

vinmassaro’s picture

Status: Needs review » Needs work

The patch in #9 does not currently apply cleanly to 7.x-1.x or 7.x-1.3 so I'm setting this to 'Needs work':

$ patch -p1 < ~/Downloads/regcode_og-labels_2278707-9.patch
patching file regcode_og/regcode_og.module
Hunk #1 FAILED at 88.
Hunk #2 FAILED at 155.
Hunk #3 FAILED at 242.
Hunk #4 succeeded at 323 (offset 27 lines).
3 out of 4 hunks FAILED -- saving rejects to file regcode_og/regcode_og.module.rej
cbrasfield’s picture

Updated patch based on comment #7. Tested against dev.

ayesh’s picture

Thanks for the patch in #9.
Attaching a rerolled patch, which applies correctly to the current 7.x-1.x head (also the 7.x-1.3 release). This is essentially the same patch, but I modified it to sanitize the label name (this module had many such security issues which set this module to abandon, which then I took it fixing them).

Can we get more hands on this please? If others can confirm this is working well, we can commit this and go for a 7.x-1.4 with this one and a few more bugs hunted!

ayesh’s picture

Oops... Two comments with different patches with 1 min difference. Sorry I didn't see #17 when submitting mine.

ayesh’s picture

Reviewing the patch in #17, it uses the node title as the OG label, where the rerolled one of #9 use entity_label to get the label, which will use the title property from node object anyway.

cbrasfield’s picture

Hi!

Thanks for the new patch!

I'm attempting to register using a code, but am getting the following warning and notice:

Warning: Missing argument 3 for regcode_og_regcode_used(), called in /modules/contrib/regcode/regcode.module on line 484 and defined in regcode_og_regcode_used() (line 334 of /modules/contrib/regcode/regcode_og/regcode_og.module).
Notice: Undefined variable: regcode in regcode_og_regcode_used() (line 336 of /modules/contrib/regcode/regcode_og/regcode_og.module).

Line 484 of regcode.module we're invoking the hook for the og_regcode_used function but not passing in the third $regcode parameter.

cbrasfield’s picture

Shouldn't this line in regcode_og.module og_group($ogid, array('entity' => $account));

be og_group('node', $ogid, array('entity' => $account)); ?

Based on og_group($group_type, $gid, $values = array(), $save_created = TRUE).

ayesh’s picture

StatusFileSize
new3.24 KB

How about this one?
The hook implementation was wrong in the previous version.

cbrasfield’s picture

Marvelous! It patches cleanly and works just splendidly. Commit! :)

Thank you!

  • Ayesh committed 1257b84 on 7.x-1.x
    Issue #2278707 by Ayesh, Lauren Kelly, cbrasfield, Offlein, scottalan:...
ayesh’s picture

Status: Needs work » Closed (fixed)

Thanks @cbrasfield.
Since no other objections were posted in two weeks, I will go ahead and commit this to the DEV, and will be included in a release soon.

held69’s picture

Status: Closed (fixed) » Active

Sorry for my late reply.
However i am still having trouble getting this to work with OG.

I have installed the latest 7.x-1.x branche

-Created a rule by picking one of my groups.
-Created a code.
-Used the code on registration.
-Used the one time link and filled in the account fields.
-Then after saving the new useraccount, the is not a member of the group i picked in my rule
nor any other group.

What am i missing?

  • Ayesh committed 1257b84 on 7.x-2.x
    Issue #2278707 by Ayesh, Lauren Kelly, cbrasfield, Offlein, scottalan:...
steinmb’s picture

Status: Active » Closed (cannot reproduce)