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.
Currently in the menu and book modules, it's possible that if the current link/page has child links, a parent that is presented in the select for new parent may be invalid because saving the link with that parent would result in a net depth greater than MENU_MAX_DEPTH.
This should be fixed by only displaying parents that are valid choices.
note - this bug noticed by webernet
Comment | File | Size | Author |
---|---|---|---|
#20 | 2nd_cleanup_plimit_2.patch | 5.86 KB | pwolanin |
#18 | 2nd_cleanup_plimit_1.patch | 5.35 KB | pwolanin |
#17 | cleanup_plimit_1.patch | 4.88 KB | pwolanin |
#14 | parent_select_limit_9.patch | 13.11 KB | pwolanin |
#12 | parent_select_limit_8.patch | 13.41 KB | pwolanin |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedstarting patch - only the book module. Works as desired, I thnk.
Comment #2
pwolanin CreditAttribution: pwolanin commenteda patch for both book and menu modules.
Actually is pretty simple.
Comment #3
pwolanin CreditAttribution: pwolanin commentedoops ran diff only on book. *this* patch has both book and menu modules.
Comment #4
webernet CreditAttribution: webernet commentedPatch looks good and works as expected - parent items that would result in the menu/book becoming too deep are not shown.
The patch needs to update the user facing text so that it explains why not all of the (theoretically) possible parents are listed.
There is also an additional case that should probably be handled for book module: the UI currently makes it possible to attempt to move the top level page of a book (that is maximum depth) to another book, even though it would result in the target book becoming too deep and thus fails with an error message.
Comment #5
Dries CreditAttribution: Dries commentedLooks good. Not committing this yet, because -- as per webernet's suggestion -- we might want to document this in the UI.
Comment #6
pwolanin CreditAttribution: pwolanin commented@Dries - webernet tells me that this patch doesn't apply cleanly on top of the one from http://drupal.org/node/154470, so I'm going to wait until that's in to re-roll with the updated description text in the UI.
Comment #7
pwolanin CreditAttribution: pwolanin commentedok, re-did the patch after that commit and added text to the form element descriptions.
Comment #8
pwolanin CreditAttribution: pwolanin commentedImproved help text with suggestions from webernet, Addi, & Heine.
Also, slightly altered the recursive function in book module so that we check the depth on every call of the function. This means the parent select may be empty if the current page is a book with children at depth == 9.
Comment #9
pwolanin CreditAttribution: pwolanin commentedbetter? Checking only in the intial if{} means that we might iterate through an extra round of recursion/level of links where none are valid. Thus, we should probably check again before the call as well.
Comment #10
webernet CreditAttribution: webernet commentedAttached patch attempts to deal with the case where the book is max depth and you should not be able to move the top level page.
Comment #11
pwolanin CreditAttribution: pwolanin commentedhmmm, webernet has thrown down the gauntlet I see after my wussy reluctance on IRC to figure out how to truncate the book select if a top level node has children out to MENU_MAX_DEPTH.
Ok, so here's a rework of his new code, plus an alternate approach to checking the depth in the other loops that may be a better tradeoff in term of simplicity.
Note in the reworked part I check if the node is, in fact, a top level node ($node->nid == $node->book['bid']) so that we avoid running the extra queries on pages not at the top level.
Comment #12
pwolanin CreditAttribution: pwolanin commentedThis patch fixes some comment typos noticed by webernet.
Also, while discussing the presentation (as well as the content) with webernet and chx of these select boxes I realized the CSS classes and IDs were lack and/or inconsistent. So, this patch also makes the menu module use a fieldset for the single item editing form (as opposed to where it's part of the node form) so that the CSS IDs are consistent (book module already does this). In addition, a couple CSS class attributes are added.
Comment #13
webernet CreditAttribution: webernet commentedThe latest patch causes some undesirable behaviour - (disabled) menu links for disabled modules are appearing the menu module parent select list.
Comment #14
pwolanin CreditAttribution: pwolanin commentedoops - I accidentally removed the check that prevented menu callbacks from being displayed in the select.
That's fixed in this patch, as well I moved the submit buttons outside the fieldset on the book outline form and the menu item editing form for consistency with other core usage.
Comment #15
webernet CreditAttribution: webernet commentedTested OK, and looks good.
Comment #16
Gábor HojtsyReviewed the code, and it looked OK, especially with the informative text for users. Committed!
Comment #17
pwolanin CreditAttribution: pwolanin commentedoops - noticed something today - this code causes some problems with after a node preview or similar operations. After this the link doesn't have the right data to run the check on the depth of the children and warnings come as:
Attached additional patch fixes this by saving the original link data for use with this check so that the check for the depth of the item's children uses the original values for the menu_name, etc (in other words the menu where it still resides in the DB) rather than what's been chosen in the select.
Comment #18
pwolanin CreditAttribution: pwolanin commentedhere's a somewhat different approach to solving the same problem.
This solution has the advantage that the query to find the depth limit is only run once, even if the node is previewed. This is also a slight disadvantage, since the depth limit is not updated upon preview (e.g. in the unlikely case another user added deeper child links).
Comment #19
Crell CreditAttribution: Crell commentedApplies cleanly. Tested it according to pwolanin's instructions and everything worked correctly without errors anywhere.
He said not to RTBC yet, though, so I'm not. :-)
Comment #20
pwolanin CreditAttribution: pwolanin commentedprevious patch didn't apply for some reason - maybe whitespace changes in block caching patch?
new patch - also combines ugly repeated code into a private function in each module.
Comment #21
webernet CreditAttribution: webernet commentedLooks and tested OK.
Comment #22
Gábor HojtsyThanks, committed.
Comment #23
(not verified) CreditAttribution: commented