The Symptom

Warning: include_once(sites/all/themes/essexdfa2/template.php): failed to open stream: No such file or directory in mailsystem_theme_theme_registry_alter() (line 45 of /home/essexdfa/public_html/sites/all/modules/mailsystem/
Warning: include_once(): Failed opening 'sites/all/themes/essexdfa2/template.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in mailsystem_theme_theme_registry_alter() (line 45 of /home/essexdfa/public_html/sites/all/modules/mailsystem/

What's Happening

When the mailsystem theme is not the same as the currently active theme - for instance if 1) you have a special theme created for mail, or 2) you're on an administration page and the administration theme is different than the default theme - mailsystem attempts to load all of its theme's preprocess code, by calling include_once() for each template.php in the theme's set of base themes.

The problem is that there are some base themes (Fusion is one example, which I happened to be using) that by default do not provide any template.php for their subthemes - at least out-of-the-box the subtheme refers back to the base theme for its preprocess functions. Mailsystem assumes, however, that there is a template.php in its theme directory and calls include_once() without checking first to see if template.php exists, causing an E_Warning to be generated.

Suggested solution:

Wrap the include_once() calls for template.php - both for the mailsystem theme and each of its (possible) base themes) - with a call to file_exists() or is_readable().

Members fund testing for the Drupal project. Drupal Association Learn more


jmarkel’s picture

Version: 7.x-2.23 » 7.x-2.33
950 bytes

Here's a patch that works for me. It's against 7.x-2.33.

jmarkel’s picture

Status: Active » Needs review
pillarsdotnet’s picture

Thanks very much for the report and patch. Will review and apply ASAP.

gittosj’s picture

Version: 7.x-2.33 » 7.x-2.34
Priority: Normal » Major
Status: Needs review » Patch (to be ported)

This bug still exists in 2.34 and the patch still fixes it. I'm using my own fusion sub-theme and suffering from the same bug. Have tested this patch and it works fine. Could we merge it with the main branch?

Many thanks in advance

pillarsdotnet’s picture

I knew I missed something in that last release.

pillarsdotnet’s picture

Status: Patch (to be ported) » Needs work

Started working on this; realized that the underlyingi function (the one you are patching) is broken. It should be caling system_find_base_themes() intead of parsing the theme data directly.

Don't have any more time today; will try to continue tomorrow.

gittosj’s picture

Thanks - much appreciated & thanks for all the great work

mlecha’s picture

Does mailsystem successfully send email using the custom theme without a template.php file, other than throwing the error?

I'm trying to find an error in my configuration. #1823270: 404 Error

Creating a blank template.php prevents the error from showing up at least.

Pascal.s’s picture

I'm a designer working on a MAC so patching didn't work out for me so far! but creating an empty template.php as a work around like suggested in #9... Now you're talking!

mrfelton’s picture

Patch in #1 resolves for me too.

ajlow’s picture

Issue summary: View changes

I do not know if my issues is related.

For some unknown reason, I am getting this warning in my logs:

Warning: include_once(): Failed opening '/var/www/html/xavier//template.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in theme() (line 1065 of /var/www/html/xavier/includes/

I have no idea why this is occurring...

Once I get this warning, mailsystem looks like it forgets the theme I set to use and defaults to my admin theme which is 'seven'.

I tried the patch and cleared the cache but I still get the warning.

My configuration is as follows:

  • Drupal: 7.41
  • Mailsystem: 7.x-2.34
  • MIME Mail: 7.x-1.0-beta4
  • SimpleNews: 7.x-1.1+0-dev
steven.wichers’s picture

Version: 7.x-2.34 » 7.x-2.x-dev
1.32 KB

Re-rolled patch against 2.x-dev

zorya’s picture

Can confirm that #1 still works for 7.x-2.34. Thanks for the fix!