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/mailsystem.theme.inc).
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/mailsystem.theme.inc).
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().
Comment | File | Size | Author |
---|---|---|---|
#13 | mailsystem-no-template-warning-1484340-13.patch | 1.32 KB | steven.wichers |
Comments
Comment #1
jmarkel CreditAttribution: jmarkel commentedHere's a patch that works for me. It's against 7.x-2.33.
Comment #2
jmarkel CreditAttribution: jmarkel commentedComment #3
pillarsdotnet CreditAttribution: pillarsdotnet commentedThanks very much for the report and patch. Will review and apply ASAP.
Comment #5
gittosj CreditAttribution: gittosj commentedThis 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
Comment #6
pillarsdotnet CreditAttribution: pillarsdotnet commentedI knew I missed something in that last release.
Comment #7
pillarsdotnet CreditAttribution: pillarsdotnet commentedStarted 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.
Comment #8
gittosj CreditAttribution: gittosj commentedThanks - much appreciated & thanks for all the great work
Comment #9
mlecha CreditAttribution: mlecha commentedDoes 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.
Comment #10
Pascal.s CreditAttribution: Pascal.s commentedI'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!
Comment #11
mrfelton CreditAttribution: mrfelton commentedPatch in #1 resolves for me too.
Comment #12
ajlow CreditAttribution: ajlow commentedI 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/theme.inc).
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:
Comment #13
steven.wichers CreditAttribution: steven.wichers as a volunteer commentedRe-rolled patch against 2.x-dev
Comment #14
jvogt CreditAttribution: jvogt as a volunteer commentedCan confirm that #1 still works for 7.x-2.34. Thanks for the fix!