0

I'm getting the following errors in dblog whenever I look at a page:

Notice: Undefined offset: 0 in _menu_check_access() (line 635 of /home/mysite/public_html/includes/menu.inc).
Notice: Undefined offset: 1 in _menu_check_access() (line 635 of /home/mysite/public_html/includes/menu.inc).

I know it's not Menu that's causing the issue, but rather, some module is passing permissions incorrectly via hook_menu.

I remember reading a long time ago that one way to find out which module is causing core to emit notices, is to drop a function right before the line in question. Alas, I cannot find that page at all.

Any thoughts?

  • 1
    Are you able to install XDebug? It makes life awfully easy and only takes about 10 minutes to setup with Eclipse – Clive Apr 15 '13 at 21:56
  • That's a thought. Alas, I'm kind of triaging a production instance that somebody else has updated -- I'd have to freshly clone the site to local. – aendrew Apr 15 '13 at 22:00
  • Bummer :/ What about a different approach - loop through the return from module_invoke_all('menu') and check that the access arguments for each is a valid, non-empty array. It'll produce some false positives (not all menu items use user_access() and not all have arguments) but it should narrow things down a bit – Clive Apr 15 '13 at 22:07
3

If you are tracking down a weird error, editing core is perfectly acceptable.

  1. Make sure everything is in your RCS.
  2. Edit includes/menu.inc
  3. Place a print_r(debug_backtrace()) near line 635, preferable at the top of _menu_check_access(). Alse print_r() the arguments.
  4. Trigger the problem.
  5. Figure out what happened.
  6. Revert the site to the checked in RCS version.

My guess is you are getting weird path, and the argument is wonky for your access check. In other words, you are trying to access check something that should really 404.

  • 1
    +1, Instead of printing entire stack, you could also print the last called function . $trace = debug_backtrace();array_shift($trace);print_r($trace[0]['function']); – GoodSp33d Apr 16 '13 at 6:17
  • I'm getting a lot of output from that and nothing's really sticking out. I'm trying to add some exception handling (Via stackoverflow.com/questions/10520390/…), but I get the unhelpful "The website encountered an unexpected error. Please try again later." message. Any thoughts? – aendrew Apr 16 '13 at 10:50
  • @2-Stroker -- That's helpful; debug_backtrace'ing a Drupal site outputs an obscene amount of text. Thanks! – aendrew Apr 16 '13 at 11:40
  • I would recommend installing the devel module and using dpm(debug_backtrace()); - It gives much more useful output for data of this scale. – rooby Apr 21 '13 at 5:45
  • Apologies for the late accept; this is a rather good answer if unable or unwilling to install debugging tools. Otherwise, Clive's suggestion to clone to local and use Xdebug is a really good idea. Using a proper development methodology is much better than trying to triage a live site! – aendrew Jan 1 '14 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.