I got the following warning when I installed this module. I had previously installed the og_mandatory_groups module:
warning: Invalid argument supplied for foreach() in /sites/all/modules/og_multiple_mandatory_groups_by_role/og_multiple_mandatory_groups_by_role.install on line 61.
The offending code is:
if (db_table_exists(og_multi_mand_groups_role_groups)) {
drupal_set_message(t('using existing Mandatory Groups for new <em>Available Groups</em> table...'));
foreach ($all as $gid => $value) {
$sql = "SELECT n.title FROM {node} n WHERE n.nid = %d";
$result = db_fetch_object(db_query($sql, $gid));
if (db_query("INSERT INTO {og_multi_mand_groups_role_groups} VALUES (%d, '%s')", $gid, $result->title)) {
drupal_set_message(t("added <em>%name</em> to the group availability table...", array('%name' => $result->title)));
}
}
}
db_query("DELETE FROM {variable} WHERE name = '%s'", 'og_mandatory_group');
There should probably be a check on the $all array:
if(! empty($all)) {
...
}
Comments
Comment #1
rconstantine commentedActually, what if on the line four lines above your quote I change the array() part of the variable_get to FALSE? Would that do the trick? It would be the first line here:
Comment #2
rconstantine commentedWell, I think that should fix it. Let me know if it is now broken worse.
Comment #3
palazis commentedI got the same warning when I installed the module without having the og_mandatory_groups module previously. Now I can't see any available groups at admin/og/og_multiple_mandatory_groups_by_role/groups page and I see the same waning there too.
Any progress on the issue?
Thanks in advance.
Comment #4
palazis commentedComment #5
rconstantine commentedDid you replace the offending code from the install file as per the above discussion? I haven't uploaded any changes yet since I don't know if the above code works or not yet. I need testers. The file isn't that long and it should be plain based on the original post in this thread which code should be replaced. Let me know if you tried it.
Comment #6
palazis commentedYes I did replace the code - In fact I have used the dev version where the code is already replaced.
The problem (warning) still exists.
Comment #7
rconstantine commentedTry this instead:
I only changed one line there.
Comment #8
rconstantine commentedWait a minute. Although I saw that you said this earlier, I forgot to ask: you say you didn't have the other module installed when you installed this one, but you got the same error; was it the same line of code that was indicated as the problem? Or was there another line mentioned? Because the function call to "db_table_exists(og_multi_mand_groups_role_groups)" should really work. If the change above doesn't work, then try this last one:
Note, the only change here is the addition of single quotes around the table name.
Comment #9
palazis commentedYou got that right - it's not a problem of the same nature most probably...
Let me try to be more precise:
After installing the module I see the following error:
"There was an error installing the OG Multiple Mandatory Groups by Role database table." No line number is indicated there.
After visiting admin/og/og_multiple_mandatory_groups_by_role I see two (2) identical records:
Role (which is empty!) and Operations (assign groups).
When I choose Available groups I see the following warning:
"warning: Invalid argument supplied for foreach() in ...public_html/includes/form.inc on line 948."
I don't understand: I have plenty of roles and groups in my site.
Trying the different versions of code mentioned here did not help.
Comment #10
rconstantine commentedThat sounds like a completely different issue. Please copy your last post into a new issue.
Comment #11
palazis commentedok.
Comment #12
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.