How to reproduce this bug:
1. Edit any existing link within your main menu
2. Take a look at your address bar in your browser and select/copy a part of your URL that looks like this: admin/structure/menu/item/373/edit
3. Paste that text as your new "Path" for the current menu item
4. Save.
It will result with an error message and after a few more refreshes - a WSOD: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 2 bytes) in /var/www/drupal7/includes/database/database.inc on line 2040
Forum topic: http://drupal.org/node/794970
D6 bug report: #796984: Self-reference protection
Comment | File | Size | Author |
---|---|---|---|
#24 | self_reference_problem-798190-22.patch | 987 bytes | psha |
#22 | self_reference_problem-798190-22.patch | 987 bytes | psha |
#18 | self_reference_problem-798190-18.patch | 921 bytes | psha |
#15 | drupal-798190.patch | 1.21 KB | ygerasimov |
#12 | drupal-798190.patch | 816 bytes | ygerasimov |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentednice bug! i can confirm this on a clean D7.
Comment #2
pwolanin CreditAttribution: pwolanin commentedan interesting bug - maybe the problem is in trying to evaluate the access callback? Or in menu_link_load()?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commented_menu_link_translate --> _menu_load_objects --> menu_link_load --> _menu_link_translate .... kaboom!
Comment #4
davidwhthomas CreditAttribution: davidwhthomas commentedConfirmed again on D7 dev
The Xdebug backtrace gives:
How could this be patched?
DT
P.S Note: this bug can be reverted at the database level by deleting the menu item from the menu_links table and clearing cache_menu and also occurs in D6
Comment #5
jazzitup CreditAttribution: jazzitup commentedMaybe it will sound awkward, but let me explain my usecase and how did I get to this bug. It may help you with choosing the right strategy for the future:
There are different roles of users building my site, and one of them (let's call them moderators) just builds the structure and conditional visibility (placeholders, dummy blocks, navigation menus, etc.), some other group (let's call them journalists) builds the content. Most of the time it's much easier for journalists not to think about administering the Drupal site.
Moderators had to prepare the whole main menu (to fill up all the design elements), and since Path is a required field (but they still didn't have the content), somehow it was natural to put their self-reference values to be easier for journalists to fill in their real path values just by clicking on those main menu items later.
Speaking of usability, maybe this could be a useful feature for some cases like mine in the future:
- Path fields for a menu item could be optional.
- All menu items with empty paths could have some kind of a warning visual sign in the menu (core CSS).
- By clicking a menu item (without a path) from the main menu could just bring an AJAX window for a user to enter its existing Path value, with exposing buttons like "Save", "Delete" and "Cancel".
Comment #6
chx CreditAttribution: chx commentedcritical: when a bug renders a module, a core system, or a popular function unusable.
normal: Bugs that just affect one piece of functionality.
Comment #7
jazzitup CreditAttribution: jazzitup commentedAccording to this comment, this is not only related to the menu module: http://drupal.org/node/794970#comment-2950302
It could also be applied to node aliases. Maybe we should name all possible occurrences of this issue.
Comment #8
ygerasimov CreditAttribution: ygerasimov commentedI have tested this bug with Drupal 7.0 alpha 2, 2010-02-21 version and no bug has been detected. I have created menu item to Navigation. Then changed the path to admin/structure/menu/item/325/edit and no WSOD. Can someone check again?
Comment #9
jazzitup CreditAttribution: jazzitup commented@ygerasimov: Can you reproduce an error message? Did you try to refresh any page with the error for a couple of times to reproduce WSOD as well?
Comment #10
ygerasimov CreditAttribution: ygerasimov commented@madjoe I was not able to reproduce error at all
Comment #11
ygerasimov CreditAttribution: ygerasimov commented@madjoe Sorry. I have reproduced error with latest 7.x-dev version. So the bug is still there.
Comment #12
ygerasimov CreditAttribution: ygerasimov commentedI think the problem is in function _menu_link_translate(). If $item has 'load_functions' that is 'menu_link_load', then it will try to load menu item using 'menu_link_load' function. This function will call _menu_link_translate() in its turn. And in this way we come to never ending loop.
I propose to change _menu_link_translate() function and let return TRUE for all items that have load_functions callback menu_link_load.
Comment #13
ygerasimov CreditAttribution: ygerasimov commentedComment #14
pwolanin CreditAttribution: pwolanin commentedpatches need to be in unified diff format. (cvs diff -rup)
Also, you've added a check regarding double-unserialize, but I don't see that as any part of the discussion above.
Comment #15
ygerasimov CreditAttribution: ygerasimov commentedThank you for the comment. Please review resubmitted patch.
I have added the check as it has been done in function _menu_load_objects() so I decided to keep that code in.
Comment #16
ygerasimov CreditAttribution: ygerasimov commentedComment #18
psha CreditAttribution: psha commentedI think the problem is that when a menu item has its 'mlid' in the link then it is infinitely being loaded, so i propose to go into _menu_load_objects function and check if the current item's mlid is the same as the argument to the load function. For my case it worked.
Comment #20
psha CreditAttribution: psha commented#18: self_reference_problem-798190-18.patch queued for re-testing.
Comment #22
psha CreditAttribution: psha commentedComment #23
ygerasimov CreditAttribution: ygerasimov commentedPatch has trailing spaces in comments. Also can we add a test to ensure that this will never happen again?
Comment #24
psha CreditAttribution: psha commentedHere it is better formatted. Haven't thought about a test. Feel free to make one.
Comment #25
johnv#24: self_reference_problem-798190-22.patch queued for re-testing.
Comment #26
johnvMarked #1921412: Menu item with path to itself causes infinite recursion as a duplicate. It has a different patch in the same function. I don't know which is best.
For convenience, this is the patch:
Also, since _menu_load_objects() is called by _menu_link_translate(), the following issue might prevent loading the same object twice: #753064: _menu_link_translate() might avoid calling _menu_load_objects()