Posted by cquincy on October 31, 2007 at 9:56pm
Jump to:
| Project: | Menu per Role |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
When using this module with postgres it reports an error that the "sequence" table is missing. The sequence table is only created when using mysql or mysqli. If you create that table anyways for postgres you will run into an issue where it can't find the value of the last menu item and then any permissions assigned when creating a new menu item won't be saved. The module appears to work correctly if the menu item is saved first and then the menu item is edited.
Current work around for me:
create sequence table in postgres to get around missing table error.
Patch menu_per_role.module as follows:
*** menu_per_role.module.orig Wed Oct 31 15:50:12 2007
--- menu_per_role.module Wed Oct 31 15:52:43 2007
*************** function menu_per_role_form_submit($form
*** 62,68 ****
--- 62,74 ----
}
else {
//a new item has been added, try to determine the mid
+
$form_values['mid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '{menu}_mid'"));
+
+ // postgress doesn't write to sequence table, look in postgres menu_mid_seq sequence
+ if (!$form_values['mid'])
+ $form_values['mid'] = db_result(db_query("SELECT last_value from {menu}_mid_seq"));
+
}
foreach ($form_values['roles'] as $rid => $checked) {
if ($checked) {
Comments
#1
IMO, a better fix is to use the
db_next_idfunction, which should work with Postgres, Mysql, and any other database providers. The patch I'm using is this:diff -u --exclude '*~' --exclude '*#' --new-file -r ../orig-modules/menu_per_role/menu_per_role.module menu_per_role/menu_per_role.module--- ../orig-modules/menu_per_role/menu_per_role.module 2007-05-31 09:41:03.000000000 +0000
+++ menu_per_role/menu_per_role.module 2008-07-25 15:10:50.000000000 +0000
@@ -62,7 +62,7 @@
}
else {
//a new item has been added, try to determine the mid
- $form_values['mid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '{menu}_mid'"));
+ $form_values['mid'] = db_next_id('{menu}_mid');
}
foreach ($form_values['roles'] as $rid => $checked) {
if ($checked) {
#2
This is now 2 years old so I'm closing it. If you can co-maintain, let us know.