I have the following errors which show up randomly when browsing the site. It's hard to reproduce, but also hard to debug. I was able to get it in the error state and have it stay during a reload in order for me to debug it.

I tried going to the code in question which resides in includes/theme.inc But when going to that line 1525. It doesn't really tell me much. The error states that its missing a tpl file, but doesn't say which one as I'm assuming its due to the $template_file variable being blank.

How can I trace where is this function being called in order to find the module that is the culprit of this error?

I don't have xdebug installed as I know that can be used to do the tracing. I also don't have experience with it neither as I've mainly solved most of my php issues just by doing a print_r() 99% of the time and I'm able to find where the issue lies, but this time its different.

What methods are there to debug it and find the source of the problem?

enter image description here

enter image description here

1 Answer 1


The Devel module can be extremely helpful in cases like this. Once installed, go to the admin/config/development/devel path, and you will see an option for additional error handlers:

enter image description here

If you select the Krumo backtrace option(s), Devel will register itself as the PHP error handler, and it can then show error messages with the full backtrace!

enter image description here

  • here's the crazy thing. once i enable any module, these errors disappear. it comes up randomly and I can't seem to figure out how to reproduce them. every time my errors popup, at most I can just reload the page and the errors will persist. But once I enable or disable any module, the errors go away.... soooo frustrating to debug this. so far I'm able to pinpoint the issue to the views module, but what and where? Commented May 7, 2016 at 19:07
  • 1
    @duckx You'll need a proper debugger to work something like that out, there isn't really a half-measure unless you get lucky. My advice would be to put some time aside and learn how to use xdebug or similar. It's more than worth that small time investment for the hours (and sanity) you'll save in years to come
    – Clive
    Commented May 7, 2016 at 19:31
  • Actually for a quick and dirty effort you could just edit the theme_render_template function temporarily to add if (empty($template_file)) { dpm(debug_backtrace()); }, or write the backtrace to a file for example if you're unable to use devel
    – Clive
    Commented May 7, 2016 at 19:34
  • @Clive I think you meant drupal_set_message(print_r(debug_backtrace(), TRUE)); because dpm comes from Devel.
    – AKS
    Commented May 7, 2016 at 19:39
  • @duckx errors in template layers are hard to debug because Drupal would have already set the page contents at that stage. You should see the error message/backtrace on the next page load if the script did not exit forcefully. Addons such as FirePHP can help, but the effort would be as same as installing xdebug on your server so I'd go down the xdebug path as clive said.
    – AKS
    Commented May 7, 2016 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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