I've been trying to debug a weird bug on Drupal 7 for awhile. It happens randomly on my site as it's hard to reproduce. I'm able to finally get ddebug_backtrace()
to run when the error happens. The error breaks all of my views on the site when it happens and throws the following error:
Warning: include(/home/xxx/public_html/.tpl.php): failed to open stream: No such file or directory in theme_render_template() (line 1534 of /home/xxx/public_html/includes/theme.inc).
It's complaining that theme_render_template()
can't find a template file as the variable given to the function is just .tpl.php.
I'm able to insert an if statement when this happens within that function as this:
if($template_file == '.tpl.php') {
ddebug_backtrace();
print_r('<pre>xxxx');
print_r('TEMPLATE FILE: ');
print_r($template_file);
print_r('</pre>');
}
I'm able to get the debug output in krumo as shown below. I'm not exactly sure what I should be looking for. I just understand that each numbered line represents where that function was called within that order. But what I'm trying to look for is a blank variable of some sort which makes it output .tpl.php to give such an error.
Judging from the output, the culprit is the Views module, but I'm not sure where. What should I be looking for exactly?
template
key when the render function is invoked fromtheme()
. Don't worry abouttheme_register_template()
, that's irrelevant - it's just working with what it's given. Go to /devel/php, rundpm(theme_get_registry(FALSE));
, and look for entries that match up with items in the args array totheme()
(views_view
etc). If any of those have an emptytemplate
, that's what's causing the problemforeach (theme_get_registry(true) as $item) { if (isset($item['template']) && empty($item['template'])) { dpm($item); } }
, that'll dump out any item that has a template key with an empty valuedpm(theme_get_registry(true));