Hey

We had a problem where a client had so many levels in the menu, it was hard to locate why it did not show all levels.

When the user selected the menu there was no problem the ajax select worked perfectly.

But when reedit the same node the menu did not re-select/show all levels, after some tests we changed the loop where $temp_items created the select boxes, I will add an diff/path for this in case you can use this approach in an update :-)

Great work with the module btw.

Comments

firebird’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have sample data that I could use to reproduce the problem? Looking at your patch, it seems to me like the loop code versions are functionally identical.

I'd be happy to include a patch that fixes a problem, but at the moment I don't see _how_ this patch should make any difference, except for the added sorts at the end of the patch file.

cheatlex’s picture

StatusFileSize
new61.42 KB

Hi again

Haven't tried on an empty solution so cant't say that I have som debug data you can get.

But could might be more precise in my explanation, I have taken the updates from the dev (that is in the patch to), the change is line 279, look at the new screenshot.

When it uses the array_pop solution we looses the last two items in the view only sowing 4 selects instead of 6 , now where we run it as an array all selects is printet.

But will try to export the menu items to an empty install, or get some php information if it could be the php version.

Kind regards
Jesper

firebird’s picture

Status: Postponed (maintainer needs more info) » Fixed

Ok, I managed to reproduce the problem on a clean installation by simply using drush generate-menus.

The (rather amateurish) bug was caused by using count() inside the for-loop definition. Since the return value of count() changes when array_pop() is run, the for-loop did unexpected things.

This is fixed now in Git. I'll create a new development release once it's available.

Please test the version in Git. If that fixes your problem, I'll release a new beta (or actually maybe even the first stable version).

Thanks for reporting the bug!

$ git diff
diff --git a/menuperformance.module b/menuperformance.module
index 08e3038..43b9d45 100644
--- a/menuperformance.module
+++ b/menuperformance.module
@@ -264,7 +264,8 @@ function menuperformance_get_form_items($default, $type = FA
     }
   }

-  for ($i = 0; $i <= count($temp_items); $i++) {
+  $c = count($temp_items);
+  for ($i = 0; $i <= $c; $i++) {
     $item = array_pop($temp_items);
     $item['#attributes']['data-mpi'] = $i;
     $form['menuperformance_node_menu_parent_link_' . $i] = $item;
cheatlex’s picture

The solution works :-)

firebird’s picture

Status: Fixed » Closed (fixed)

The fix is included in the new beta-4 build.