Great module! But ...
I tested og_menu together with panels. I got a 'huge' amount of error messages Warning: preg_match () expects parameter 2 to Be string, array given in / var / www / html / includes / bootstrap.inc on line 777th
I think this is due to incompatibility of output of the og_menu_get_menus with 'menu system' in Drupal core. My problem solved small change:
Original:
function og_menu_get_menus($gids = NULL, $user = NULL) {
if (!$user) {
global $user;
}
if (!$gids) {
$gids = array_keys($user->og_groups);
}
$menus = array();
if ($gids) {
$result = db_query("SELECT * FROM {menu_custom} m INNER JOIN {og_menu} om ON m.menu_name = om.menu_name WHERE om.gid IN (". db_placeholders($gids, "int"). ") ORDER BY m.title", $gids);
while ($menu = db_fetch_array($result)) {
$menus[] = $menu;
}
}
return $menus;
}
My modification:
function og_menu_get_menus($gids = NULL, $user = NULL, $og_module = FALSE) {
if (!$user) {
global $user;
}
if (!$gids) {
$gids = array_keys($user->og_groups);
}
$menus = array();
if ($gids) {
$result = db_query("SELECT * FROM {menu_custom} m INNER JOIN {og_menu} om ON m.menu_name = om.menu_name WHERE om.gid IN (". db_placeholders($gids, "int"). ") ORDER BY m.title", $gids);
while ($menu = db_fetch_array($result)) {
if ($og_module == FALSE) {
// that's the trick
$menus[$menu['m.menu_name']] = $menu['m.title'];
} else {
$menus[] = $menu;
}
}
}
return $menus;
}
All instances of the function in og_module are then called og_menu_get_menus( , , TRUE). It works without problems (for my site :-)).
Regards Tomas
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | og_menu-793854.1.patch | 3.79 KB | evoltech |
| #2 | candice.png | 31.03 KB | evoltech |
Comments
Comment #1
penguininja commentedThis error also occurs when using OG Menu with the Menu Block module (http://drupal.org/project/menu_block). I'm using a clean 6.16 install, Organic Groups 6.x-2.1, OG Menu 6.x-2.0, and Menu Block 6.x-2.3.
Steps to reproduce:
1. Required modules: OG, OG Menu, Menu Block
2. Create an organic group with an OG menu ("Enable menu for this group" box is checked)
3. Go to /admin/settings/menu_block
4. For each group with an OG menu, there will be a menu with a blank title in the list*
5. There will also be 2 "warning: preg_match() expects parameter 2 to be string, array given in...bootstrap.inc on line 777." errors for each OG Menu
* Note: This only seems to occur for the groups that the logged-in user is a member of. Also, this error does not appear to affect the functionality of either Og Menu or Menu Block.
Is this on the radar at all? Thanks for your time, it would be great to be able to use OG Menu and Menu Block together without this error.
Comment #2
evoltech commentedI was able to reproduce the error described by penguininja in #1
Comment #3
bonobo commentedChanging title to more remove editorial comments on the error :)
Comment #4
evoltech commentedThe problem seems to be in menu_block.module:menu_block_get_all_menus()
The error message does not happen. I see that the solution above for og_menu_get_menus would solve this problem as well, but maybe the issue is that the menu_block module is actually implementing hook_get_menus (not menu.module as I initially expected), and og_menu unintentionally implements it?
Comment #5
jide commentedThank you everyone for digging into this issue.
This is definitely because og_menu uses a function named og_menu_get_menus() which conflicts with hook_get_menus(). I'll have to rename og_menu_get_menus() to _og_menu_get_menus() as I should have from the start, although a hook named hook_get_menus() seems kind of dangerous to me.
As a quick fix until I provide an update, you could replace all occurrences of "og_menu_get_menus" by "_ og_menu_get_menus" in og_menu.module.
Comment #6
jgraham commentedChanged ticket title to reflect actual problem.
The symptom is a preg_match() warning such as:
Also, I would recommend the name change to 'og_menu_get_custom_menus' rather than '_og_menu_get_menus' as from my experience '_' pre-pended to a function name typically means 'reserved for internal use' and not to resolve namespace collisions.
Comment #7
evoltech commentedPlease see patch (against 6.x-2.x-dev? not 6.x-2.x) that fixes this issue by applying the changes recommended by jgraham in #6
Comment #8
penguininja commentedEvoltech's patch in comment #7 is working for me. I am not seeing any more preg_match errors or blank menu entries, and both Menu Block and OG Menu appear to be functioning correctly. Thanks!
Comment #9
penguininja commentedFYI, I tested this patch successfully against 6.x-2.0.
Comment #10
bonobo commentedFrom the release page, the dev release and the point release appear to be the same code, and both were released on the same day.
Comment #11
jide commentedFixed in CVS. I renamed the function og_menu_get_custom_menus() instead.
Comment #13
fuerst commentedJust for the files: At least in og_menu-2.4 the function
og_menu_get_menus()is renamed toog_menu_get_group_menus().Comment #14
rv0 commentedAlso renaming this in D7 version for consistency.