Closed (fixed)
Project:
Organic Groups - Multiple Mandatory Groups by Role
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Oct 2007 at 19:09 UTC
Updated:
14 Jan 2008 at 17:37 UTC
Comments
Comment #1
rconstantine commentedOkay. First thing to do is to check and see if the two database tables were even created. If they weren't, let me know - that might signify a problem with your database user's permissions.
Next, if the tables are created, check the contents of them. One of them should have some fake roles defined - "All users" and "Group owners" or something like that. Tell me if one or both are missing.
Those are the only causes for that first error message. There are 4 queries executed at install, create table 1, create table 2, insert role 1, insert role 2. That's it. Let me know.
Comment #2
palazis commentedOK, thanks for the answer.
The first table (og_multi_mand_groups_role) has been created but it's empty.
I guess this explains the two empty records that I see when I visit admin/og/og_multiple_mandatory_groups_by_role.
The second table (og_multi_mand_groups_role_groups) has NOT been created.
A problem with my database user's permissions would be very strange since I never had any problems to create a table or install any other module.
Comment #3
rconstantine commentedWhat version of MySQL are you using? 4.x I'm guessing. I don't think 4.x likes these lines: /*!40100 DEFAULT CHARACTER SET utf8 */ in the install file. Try uninstalling the module (you'll get errors, but ignore them), and then reinstalling after you delete the code like that one. Don't delete the parenthesis just before that code. You need it in both places.
In other words, change this:
) /*!40100 DEFAULT CHARACTER SET utf8 */to this:)in both places for your database.Comment #4
palazis commentedI use MySQL database 4.1.22 and PHP 5.0.5.
I have uninstalled the module (without any errors), deleted the comments as instructed and re-installed but still I have the same result.
The two tables are created but they are empty (I forgot to mention that even the second one is there - the long name just got me confused, sorry) and I have the same error.
I also did another thing: Copied the mysqli code to the mysql part of the switch part. No luck! I guess I should go to bed! Thanks anyway!
Comment #5
rconstantine commentedYou can try to execute the SQL queries that go along with $query3, and $query4 manually from within phpmyadmin or similar.
INSERT INTO og_multi_mand_groups_role VALUES (-1, 'All users', '');
INSERT INTO og_multi_mand_groups_role VALUES (0, 'Group admins', '');
If you have a prefix on your tables, adjust table names as needed.
Refresh my memory, did you, or did you not have the regular og_mandatory_group module previously installed? Do you still have these variables: og_mandatory_group_admin & og_mandatory_group in your variables table? If you do, perhaps that is where the problem lies. It won't matter if that module is installed or not because it leaves behind these variables (i.e. doesn't clean up after itself).
Comment #6
palazis commentedSorry if I got you confused - my english is not so perfect and my knowledge of drupal is not so deep.
I have NOT installed the regular og_mandatory_group module previously.
After checking my variable table I have confirmed that I don't have these variables: og_mandatory_group_admin & og_mandatory_group.
After I executed $query3 and $query4 manually as you instructed, the two records are inserted. Maybe there's a problem with the "serialize" function in the install script.
Anyway, I can now see "All users" and "Group admins" roles when I visit admin/og/og_multiple_mandatory_groups_by_role.
But unfortunately after I hit "Available Groups" I have the same old warning (form.inc on line 948).
Another IMPORTANT thing:
When I tried to add a new open group, after pressing submit, I got this new warning:
warning: array_sum() [function.array-sum]: The argument should be an array in .../public_html/sites/all/modules/og_multiple_mandatory_groups_by_role/og_multiple_mandatory_groups_by_role.module on line 825.
But (surprise, surprise!) now when I hit "Available Groups" I don't have the same old warning (form.inc on line 948)!
I can see my new open group there in the list! It's the only one there!
Detail: All my previous groups were closed ones.
Maybe the og_multiple_mandatory_groups_by_role module has a problem with closed groups OR
Someone should FIRST install this module and add his groups AFTERWARDS.
Any ideas?
Comment #7
rconstantine commentedThat gives me more to look at, so that's progress. The devel module would be useful here to find out where the form.inc errors originate from. Use the 'backtrace' feature. This my my first module. Since then, I've learned a lot more. Perhaps it's as simple as checking to see if an array is empty before trying to execute certain parts of code. So try the devel module and let me know.
Comment #8
palazis commentedI have no experience with the devel module, but I can try to install and use it.
It might not be easy to re-produce the same behavior again - I might have to unistall and install once again the og_multiple_mandatory_groups_by_role module...
In case I have more info, I will add a new answer here.
Comment #9
rconstantine commentedI don't want you to waste your time. Perhaps if someone else has a similar issue, simply reading this post will help them and they can try to give the devel info. However, that would mean I'll have to wait until someone else has a problem before I can think about fixing it. Not ideal, but if you've got deadlines, etc., I don't want to keep you from them.
Comment #10
jpuddy commentedI'm getting a similar issue. When I try and edit one of the pages I've got, I get the following:
warning: Invalid argument supplied for foreach() in [paths hidden by me]/includes/form.inc on line 948.
I also get an error when I view the page. It is:
* 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 'NOT IN ('25') OR .tid IS NULL))' at line 1 query: SELECT count( DISTINCT(node.nid)) FROM node node WHERE (node.type IN ('prayerpost')) AND ((.tid NOT IN ('25') OR .tid IS NULL)) in [paths hidden by me]/includes/database.mysql.inc on line 172.
* 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 'NOT IN ('25') OR .tid IS NULL)) ORDER BY node_created_created DESC LIMIT 0, 20' at line 1 query: SELECT DISTINCT(node.nid), node.created AS node_created_created FROM node node WHERE (node.type IN ('prayerpost')) AND ((.tid NOT IN ('25') OR .tid IS NULL)) ORDER BY node_created_created DESC LIMIT 0, 20 in [paths hidden by me]/includes/database.mysql.inc on line 172.
We're on MySQL 5.0.48 and PHP 5.1.6. We're seeing this error after migrating to a new host (we're dedicated though, so I can change anything I need to).
Comment #11
moshe weitzman commentedComment #12
rconstantine commentedUnfortunately, I don't see anything in your message that would indicate a definite problem originating in this module. It you indeed have a problem with OG, and not this module, it is better that you open a new issue as you can clearly see that the maintainer of OG doesn't appreciate tack-on problems to other issues being moved to his queue.
Comment #13
sethcohn commentedFound this bug during a debugging of a site.
Turns out that if you have roles assigned when creating a new user, even if All Users is set correctly, the extra role (which MMG doesn't know about) throws an error like so:
warning: Invalid argument supplied for foreach()
in [...]/sites/all/modules/og_multiple_mandatory_groups_by_role/
og_multiple_mandatory_groups_by_role.module on line 924.
I suspect it's hitting the assigned group and not dealing with the empty result set here:
$mandatory_groups = unserialize($result->mand_groups);
foreach ($mandatory_groups as $key_g => $value_g) {
Comment #14
sethcohn commentedShort term fix:
make sure all roles have been entered into MMG, even if they have no groups attached to them. No error then.
Comment #15
rconstantine commentedThe error you are getting occurs well in advance of the code you quoted which happens when the user is inserted. Line 924 has to do with the registration form.
Question: Do you have (want) a group to be mandatory for all users? If not, you should not have to set it.
Likewise, you should not have to include all roles in the admin for this module. I certainly never have.
Regarding line 924, the only foreach in the vicinity (which makes me wonder if you're using the latest version), uses the array of mandatory groups from the database. So an error there tells me that the database doesn't have the correct values stored, which tells me that perhaps something is wrong with your admin settings for MMG. Perhaps you could include some screen shots of your settings?
You could also try to print the contents of the mandatory group array just before the line that gives you the error so that we know why it doesn't like the argument. You can use the devel module on 'backtrace' mode, then save the 'complete' page and zip/attach it to your next post. What that does is tell us each function call and all arguments leading up to the crash.
Comment #16
sethcohn commentedIndeed, wasn't the latest version of code. (I've since updated it...) "Never mind" - Emily Litella
Comment #17
rconstantine commented