Using a recent CVS version of OG on a drupal 4.7-cvs installation:
$Id: og_mandatory_group.module,v 1.2 2006/03/04 17:37:36 weitzman Exp $
When I enable og_mandatory_group, and then try to register a new user, I get a fatal error:
Fatal error: Call to undefined function: og_create_subscription() in /home/prince14/public_html/modules/og/contrib/og_mandatory_group/og_mandatory_group.module on line 24
From a manual comparison with between these two versions of og.module:
$Id: og.module,v 1.138 2006/03/01 17:26:32 webchick Exp $
$Id: og.module,v 1.148 2006/03/28 21:20:21 weitzman Exp $
it looks as though the function name in og.module was changed from og_create_subscription() to og_save_subscription().
Changing this function call to see if that fixes it, I get the following errors instead:
* warning: Invalid argument supplied for foreach() in /home/prince14/public_html/modules/og/contrib/og_mandatory_group/og_mandatory_group.module on line 33.
* warning: array_keys(): The first argument should be an array in /home/prince14/public_html/modules/user.module on line 339.
* warning: implode(): Bad arguments. in /home/prince14/public_html/modules/user.module on line 339.
* user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT DISTINCT(p.perm) FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /home/prince14/public_html/includes/database.mysql.inc on line 120.
* warning: array_keys(): The first argument should be an array in /home/prince14/public_html/modules/user.module on line 339.
* warning: implode(): Bad arguments. in /home/prince14/public_html/modules/user.module on line 339.
* user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT DISTINCT(p.perm) FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /home/prince14/public_html/includes/database.mysql.inc on line 120.
These errors seem to be of the same nature as what I reported before at http://drupal.org/node/52346
Again, the outcome is that the user is added to the mandatory group, but I don't want to have new users scared off by this kind of error message.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | og_mandatory_group.zip | 4.83 KB | pwolanin |
| #12 | og_mandatory_2.patch | 3.09 KB | pwolanin |
| #4 | og_mandatory_1.patch | 1.25 KB | pwolanin |
| #2 | og_mandatory_0.patch | 1.34 KB | pwolanin |
Comments
Comment #1
moshe weitzman commentedi fixed the wrong function name. no time to investigate other issue". perhaps contact the author of this module. he might have his checkbox values mixed up.
Comment #2
pwolanin commentedI have, I think, corrected the next bug "warning: Invalid argument supplied for foreach()" on line 33 of the module in the attached patch. Thanks to Zack who's 4.7 port of this module at www.zacker.org had this line corrected and confirmed my thought as to how to fix it.
I also prevented the remainder of the errors by commenting out a call to the user.module function "user_access()" on line 62. Not a real fix, but
(for me at least) there is no loss in functionality because the function call resulted in an error anyhow. The purpose of the function call is to determine whether to add a helpful line to the notification e-mail.
Comment #3
pwolanin commentedeurka- I think I found the problem. The last batch of errors are from this function:
http://api.drupal.org/api/HEAD/function/user_access
The implode statment references:
$account->rolesHowever, in og.module, the SQL query returns only some fields from {user} and {og_user}
In contrast, the
user_access()function expects the full $user object generated byuser_load()which includes #user->roles. So, the function call touser_access,/code> is passing an invalid parameter.Comment #4
pwolanin commentedOk, after my insight above and too much browsing of user.module, I think the attached patch brings the full intended functionality to this module. Tested using 4.7RC3, PHP 4.3.10, mySQL 4.0.25. Please review/test/commit and maybe move this module back into the 4.7 branch of OG.
-Peter
Comment #5
ajwwong commentedPatch works:
Upon new registration, users were getting the scary message --
Thanks to the patch, this scary message has gone away.
I don't know the inner workings of the patch, or the mechanics of *how* it works, but it does trick.
I don't know appropriate policy on this, or if this patch actually needs further review, but I'm marking as RTC.
Comment #6
pwolanin commentedThe full (most recent) patch should not only make the scary error messages go away, but also any group admins who have the 'administer users' permission should now have received an e-mail that includes a link to administer the account of the newly-joined user.
-Peter
Comment #7
pwolanin commentedI'm pretty confident that this patch is, indeed, ready to be committed. Please let me know...
Comment #8
killes@www.drop.org commented$registered = array(0);
- foreach ($edit['og_register'] as $key => $value) {
+ if ($edit['og_register']) {
$registered[] = ($value ? $key : 0);
}
I am not sure that will work for more than one group
Comment #9
pwolanin commented@killes - thanks for reviewing this.
I'm looking at the code with a fresh eye and I'm now thinking, perhaps, the foreach is needed, but the usage was wrong in some other way. This current patch has been working for me since I don't have any groups available during registration.
A better patch to follow.
Comment #10
dwwComment #11
pwolanin commentedBelow is a fragment of the code from og.module for the 'insert' case in hook_user. From the SQL query, it looks as though this was changed as part of the "let any node be a group" reform.
I will use this same logic in place of the foreach().
Comment #12
pwolanin commentedrevised patch attached- does work for me to send e-mail describing groups joined during registration form.
Comment #13
pwolanin commentedpatched module, plus orig and README attached in a .zip for those who want to easily test the patch in #12.
Comment #14
jdsaward commentedJust confirming that I downloaded and installed and used the mandatory group module with no errors and no pain.
I had a recipe problem which I received help with and wrote this:
'I have installed the latest version of og_mandatory_group that I could find. I set it to make the "Members" group the mandatory group and indeed as soon as I added a new test-user that user belonged to the mandatory group but no other group. Works like magic.'
I was requested to follow up here; to complete the documentation. So I am.
Comment #15
pwolanin commentedCommited changes- working 4.7 version now available for download:
http://drupal.org/project/og_mandatory_group
Comment #16
(not verified) commented