Reproduced from a fresh install:

Create a new book (page 1)
Added pages 2-6 (2 is child of 1, 3 is child of 2...)
Added pages 2b-6b (2b is child of 1, 3b is child of 2b...)

Resulting hierarchy:
1
-2
--3
---4
----5
-----6
-2b
--3b
---4b
----5b
-----6b

Moved 6b to be child of 5
Moved 6 to be child of 5b

Resulting hierarchy:
1
-2
--3
---4
----5
-----6b
-2b
--3b
---4b
-----6
----5b

Note that 6 appears as a child of 4b, not 5b (though it is on the 6th level).

CommentFileSizeAuthor
#4 level6_bug_1.patch3.54 KBpwolanin

Comments

pwolanin’s picture

ok, following these exact steps I can reproduce the bug. I'm using PHP 4.4 on OS X, webernet is using XAMPP (PHP 5.2.3), so seems not to be a PHP issue.

So my guess is a 99% liklihood the bug is in function _menu_tree_data(). The render function, menu_tree_output(), is too simple to have a subtle bug.

pwolanin’s picture

confirmed that the data coming out of _menu_tree_data() has the wrong structure.

Somehow it seems that 6 is getting set as directly 'below' 4b, while 5b is incorrectly set as a sibling of 4b.

pwolanin’s picture

ok, here's a CLI query result - looks correct:

mysql> SELECT mlid, plid, link_title, depth, p1, p2, p3, p4, p5, p6 FROM menu_links WHERE menu_name = 'book-toc-1' AND plid IN(0, 115, 121, 122, 123, 124) ORDER by p1, p2, p3, p4, p5; 
+------+------+------------+-------+-----+-----+-----+-----+-----+-----+
| mlid | plid | link_title | depth | p1  | p2  | p3  | p4  | p5  | p6  |
+------+------+------------+-------+-----+-----+-----+-----+-----+-----+
|  115 |    0 | page1      |     1 | 115 |   0 |   0 |   0 |   0 |   0 |
|  116 |  115 | page2      |     2 | 115 | 116 |   0 |   0 |   0 |   0 |
|  121 |  115 | 2b         |     2 | 115 | 121 |   0 |   0 |   0 |   0 |
|  122 |  121 | 3b         |     3 | 115 | 121 | 122 |   0 |   0 |   0 |
|  123 |  122 | 4b         |     4 | 115 | 121 | 122 | 123 |   0 |   0 |
|  124 |  123 | 5b         |     5 | 115 | 121 | 122 | 123 | 124 |   0 |
|  120 |  124 | page6      |     6 | 115 | 121 | 122 | 123 | 124 | 120 |
+------+------+------------+-------+-----+-----+-----+-----+-----+-----+

This query corresponds to viewing "page6" or "5b". Viewing "4b" the menu renders correctly (i.e. "5b" appears to be below "4b").

here's how it looks:

+ page1
      + 2b
            + 3b
                  + 4b
                        * page6
                  + 5b

vs the correct structure when 4b is the active link:

+ page1
      + 2b
            + 3b
                  * 4b
                        + 5b
pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new3.54 KB

Ah, looking at the query results above gave me the possible solution - we DO need to ORDER BY p6 (or pN where N = MENU_MAX_DEPTH) to insure that all children are returned in a query AFTER their parent.

Starter patch attached. This corrects the problem for me.

pwolanin’s picture

Note this also explains why the bug appears to be sporadic - it will only be in evidence when a link at depth 6 has a mlid that is less than that of its parent.

I think the patch above should just be considered proof-of-principle for the fix. The real fix will be included in this patch: http://drupal.org/node/154470

pwolanin’s picture

Status: Needs review » Closed (duplicate)