Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I think this bug is in function _menu_link_move_children() in menu.inc.
If a link with children is moved so that it is at a greater depth than before, it's children are assigned the wrong p1-p6 values.
This can be seen with either the menu module or the book module as patched to use the menu API.
Comment | File | Size | Author |
---|---|---|---|
#10 | menu_link_move_4.patch | 3.39 KB | pwolanin |
#5 | menu_link_move_3.patch | 2.88 KB | pwolanin |
#4 | menu_link_move_2.patch | 2.82 KB | pwolanin |
#3 | menu_link_move_1.patch | 2.44 KB | pwolanin |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedComment #2
pwolanin CreditAttribution: pwolanin commentedOk, I found the problem - here's an example up the update query:
SET menu_name = '%s', depth = depth + %d, p1 = %d, p2 = %d, p3 = p2, p4 = p3, p5 = p4, p6 = p5
Apparently MySQL is using the new value of p2 to update p3, and then then new value of p3 (now == p2) to update p4, etc. So the arguments need to be written in the opposite order for this case (moving to a deeper level).
Something like:
SET menu_name = '%s', depth = depth + %d, p6 = p5, p5 = p4, p4 = p3, p3 = p2, p2 = %d, p1 = %d
Comment #3
pwolanin CreditAttribution: pwolanin commentedrewrite of this function - seems to solve the issue. The parameters of the query get reordered as needed.
Comment #4
pwolanin CreditAttribution: pwolanin commentedslightly better patch - simplifies the update query so it should use the available index and fixes up doxygen docs.
Comment #5
pwolanin CreditAttribution: pwolanin commentedmore cleanup from suggestions by Karoly.
Comment #6
chx CreditAttribution: chx commentedComment #7
hswong3i CreditAttribution: hswong3i commentedi check it with latest oracle driver, with menus:
with following tables value:
after update to:
data becomes:
i hope it should be fine, even without this patch, in case of oracle :)
Comment #8
Gábor Hojtsy- "Update the the children" does seem to be a typo
- The last query in the patch could use single quotes instead of double quotes
- I don't see that either chx or hswong3i actually tested the patch; hswong3i specifically mentions the behaviour *before* this patch
Comment #9
hswong3i CreditAttribution: hswong3i commentedpwolanin ask me to test the case without patch, as he hope to clarify if it is really required for oracle driver,too ;)
Comment #10
pwolanin CreditAttribution: pwolanin commentedfixes doxygen comments.
Comment #11
pwolanin CreditAttribution: pwolanin commentednot- chx tested before setting RTBC above.
Also, on a side note, this won't be an issue for SQLite since during updates "All expressions are evaluated before any assignments are made. "
Comment #12
Gábor HojtsyIt would help if chx would not only set the issue to RTBC, but would care to write a few kinds words what he has done and found. If I see a patch set to RTBC without a comment, I don't see a reason not to set it back to CNR immediately.
Comment #13
eaton CreditAttribution: eaton commentedI've taken some time to poke through reproducing the bug, and tested the fix, and the changes definitely resolve the issue as I can see it without breaking other stuff. I've taken a look at the code itself and it doesn't appear broken in a visible way, but I will be the first to admit that I don't have a deep understanding of the internals of the menu system yet.
I'll take some time to pore over it in more detail when I'm able to tonight -- without that I won't RTBC, but I can say the bug is reproducable and the patch fixes it reliably.
Comment #14
pwolanin CreditAttribution: pwolanin commentedChad (hunmonk) was kind enough to check for this bug on PostgreSQL, and it seems not to occur there.
Here's the test: move "Create content" (path = 'node/add') and make it a child of "My Account". Run the query "select * from menu_links where link_path like 'node/add%';"
without the patch, the relevant {menu_links} data from his PostgreSQL table (correct p1 .. p6):
without the patch the relevant {menu_links} data in my MySQL 4.1 table, exhibiting the bug:
Comment #15
chx CreditAttribution: chx commentedI tested it, others tested, all databases are happy, so...
Comment #16
Gábor HojtsyGood, thanks. Committed!
Comment #17
(not verified) CreditAttribution: commented