If the current theme is not the mail theme, mailsystem_theme_theme_registry_alter() alters the theme registry by loading the mail theme in addition to the current theme.
So when the cache is cleared and theme_a is active, drupal first initializes theme_a and additionally theme_b (our mail theme). Due to the fact that drupal_alter caches the available functions, out hook_alter functions in out theme_b's template.php (or theme_b's base theme) don't get called, because these functions weren't loaded when theme_a got initialized.
This leaves theme_b (our mail theme) in an initialized, but broken state, as none of the themes alter hooks have been loaded.
Comment | File | Size | Author |
---|---|---|---|
#65 | mailsystem-theme-registry-2051135-65-do-not-test.patch | 2.64 KB | Tom Verhaeghe |
#48 | mailsystem-theme-registry-2051135-48.patch | 2.54 KB | robcarr |
| |||
#44 | mailsystem-theme-registry-2051135-44.patch | 2.54 KB | oriol_e9g |
| |||
#13 | mailsystem-theme_registry-2051135-13.interdiff.txt | 2.06 KB | malberts |
#13 | mailsystem-theme_registry-2051135-13.patch | 2.54 KB | malberts |
|
Comments
Comment #1
mjpa CreditAttribution: mjpa commentedNot 100% why mailsystem builds the mail theme registry when it's not the active theme but I won't question that and instead will give you this patch... I'm not convinced it's the completely proper way to fix this but it works for me with an Omega based subtheme.
Comment #2
mjpa CreditAttribution: mjpa commentedPatch in #1 has a typo in, doesn't appear to affect anything except a PHP notice but here's a fixed patch.
Comment #3
flocondetoilePatch #2 solved same issue on a omega 4.x subtheme.
Thanks @mjpa
Comment #4
plachPatch #2 is working here, I'd RTBC it but I needed and additional fix for a related issue: my custom theme uses some functions from the base theme, which is currently loaded after the child causing a "function not found" fatal error to be thrown. If the interdiff looks good we can RTBC this.
Comment #5
valentin schmid CreditAttribution: valentin schmid commentedPatch #3 fixed "Undefined variable: row_attributes" in "views-view-unformatted.tpl.php" bug here.
We also use an Omega based subtheme here while facing this problem.
Thanks all.
Comment #6
markhalliwellI can confirm this works.
Comment #7
Fabianx CreditAttribution: Fabianx commentedThe patch is RTBC indeed, but it should definitely not be needed.
I would say there is a deeper bug within mail system, which is circumvented here.
Comment #9
Les LimCommitted #4 to 7.x-3.x-dev, which isn't to say that there isn't room to revisit the entire thing.
Leaving this open for the 2.x branch, which I haven't touched.
Comment #10
das-peter CreditAttribution: das-peter commentedWow, very evil.
I just spent hours to figure out why flushing the cache sometimes leads to a broken frontend theme. Turns out flushing the cache in the back-end triggers
if ($mailsystem_theme != $theme_key) {
and thus this bug (frontend theme is set as mail theme atm.).I really want to see this patch in and keep it on RTBC but here some nitpicks I've found:
Inline comments must end in full-stops, exclamation marks, or question marks.
Comment #11
joelpittet2 hours on the debug train myself and a few days before that going WTF and removing modules and comparing old db schemas.
Please commit to 2.x-dev
RTBC++
Comment #12
kle CreditAttribution: kle commentedA way to change the theme to "admin-theme" if a newsletter is sent (by cron or by drush-cron).
First: it is not possible to detect a cron-run in hook_custom_theme() because on drush-cron there is no 'cron_key'.
Idea:
simplenews-newsletter.body.tpl.php
) I callmy_newsletter_set_admintheme()
That's the function:
Comment #13
malberts CreditAttribution: malberts commentedHere's a reroll of #4 with the comments in #10.
What do we need for this to get in to 2.x? Since nothing has been done on the 2.x branch in two years, does this mean that changes are only going in to 3.x?
Comment #14
pun_pun CreditAttribution: pun_pun commentedHello!
#13 doesn't solve the problem described here
Comment #15
dxx CreditAttribution: dxx commented+1 for #14.
This warning occured during sending email via Rules and Message after editing an order:
And this report event from message_notify:
Could not send message using @title to user ID 141.
Environment:
I use Drupal Commerce kickstart (2x) with this related modules:
Trying to disable parent themes:
If (line 63 with this patch) I comment out this line, all warning disappears but email is not sent (Could not send message using @title...):
...but mail not sent:
"dpm($theme_registry)" called line 82:
Comment #16
dxx CreditAttribution: dxx commentedComment #17
dxx CreditAttribution: dxx commentedComment #18
markhalliwell@comexpertise, this patch is for the 7.x-2.x branch. It was already committed to 7.x-3.x (#8).
That being said, I am leaning more towards agreeing with @Fabianx (#7). This module is doing some really nasty stuff in how it's altering the theme registry. It's very hackish at best, which can ultimately cause many different issues with other modules/themes when they expect the theme registry to be relatively stable. This module should find a different, more stable, way to output emails in the correct theme.
This begs the question though, does this module even theme any mail messages?? I have been looking through the repo and cannot find any place it actually uses
theme()
. The only thing I can find is in Mime Mail and HTML Mail.This is where any "theme switching" should probably happen, right before any
theme()
is invoked and then switched back the the current theme after it's called.P.S. it would be nice to get some maintainer feedback. What is trying to be accomplished with these alterations exactly? The comments and code aren't exactly self-explanatory.
Comment #19
joelpittet@Mark Carver the recommended release is still at 2, this needs a backport to 2.x as long as that is the case.
I agree we should entertain the idea that it doesn't need the theme switching support but first, it would prevent a lot of heartache if the patch was backported. That bug was SOOO nasty.
EDIT: want to echo:
Comment #20
markhalliwellThe reason I moved it to 7.x-3.x is because even with the patch that was committed in #8, this "solution" isn't really a solution at all.. it's just a temporary hack to get things relatively "working". This is also why I changed the title, since this implementation of the hook_theme_registry_alter() is potentially breaking everything. Once something more stable (or a different approach entirely) has been figured out, it should be committed to both branches, so I'm leaving the tag you just added.
Comment #21
dxx CreditAttribution: dxx commentedAll emails are successfully sent with rules fired from front-office but not working from back-office.
Comment #22
dxx CreditAttribution: dxx commentedTested with 7.x-2 and 7.x-3.x-dev.
Mails are successfully sent if "Mimemail" is used for sending mail into "Site-wide default" option. But SMTP is not used...
And these errors are still there of course:
Content of my (disabled) MimeMailSystem__SmtpMailSystem class:
Comment #23
markhalliwell@comexpertise, yes it is nice to have answers. Unfortunately, there are no real answers yet. You will have to be patient until either a) someone has time to really debug what's going on here (I do not have time ATM) and/or b) we get some feedback from the maintainers as to why
hook_theme_registry_alter()
is being used in this fashion. Regarding the omega/bootstrap errors that this particular implementation has created, they will get resolved when this one does. As far as why the first class in #22 isn't working, I am not sure and is likely an entirely separate issue from this one.Comment #24
dxx CreditAttribution: dxx commentedYou're right my comment # 22 does not apply to this issue, that's another problem in itself.
Comment #25
Fabianx CreditAttribution: Fabianx commentedI took a look:
a) The patch should just be committed by Les Lim to 7.x-2.x.
I took a look at the history and 3.x is around 10 commits farther than 2.x, so this is a just get it in and get a new stable release out.
It fixes a critical. Someone should contact him directly on it.
b) I took a good look and I don't even see why the theme registry alter is needed at all.
Did someone try what happens if you completely remove it?
I assume the reason is that you cannot render something in a different theme while another theme is running.
However, for this a new API module should be created whose sole purpose is to "switch_theme" and then mail_system ported to use it.
Changing the registry is not the right way, even if the intention was good.
Comment #26
joelpittetI've contacted Les through d.o. we can wait and see.
Comment #27
Les LimI have to admit to not understanding the use of hook_theme_registry_alter() here, either -- that work pre-dates my involvement and it's never come into play for my own use cases.
Based on the git logs, the original work on this was developed in #1382036: Add a common way to configure the theme that will render the email. Miro or Berdir might be able to provide more insight, and both are also co-maintainers.
Comment #28
joelpittetThanks for the feedback @Les Lim, any chance you can commit the stop-gap fix to 2.x as well and we can spin off the removal/refactoring of that theme swapping in another issue?
Comment #29
Jax CreditAttribution: Jax commentedIt seems this doesn't happen anymore after an upgrade to Drupal 7.34.
Comment #30
valentin schmid CreditAttribution: valentin schmid commentedPatch (#3 or #14) still needed in Drupal 7.34 with Omega based subtheme.
Comment #31
dxx CreditAttribution: dxx commented+1 for #30.
Notice: The path do not resolve all related issues: https://www.drupal.org/node/1763362#comment-6790982
Comment #32
markhalliwellI've re-opened: #1763362-27: Omega does not work with Mail System module. Please direct your comments there.
I still think fixing this on a base-theme level is wrong and shouldn't be needed at all. The patch here is still a "hack" (since Omega still has an issue), but I'm not touching the status of this issue in hopes that even this temporarily solution can be committed to the 7.x-2.x branch.
This module should re-examine why/how it's altering the theme registry to accomplish something that (seemingly) isn't used by any other contrib module in the first place. Once a final solution has been determined, it should be committed to both 7.x-2.x and 7.x-3.x.
Comment #33
ccarrascal CreditAttribution: ccarrascal commentedPatch #13 solved the problem after upgrading to 7.34 core.
Comment #34
AlexKirienko CreditAttribution: AlexKirienko at WikiJob commentedThis is pretty bad bug, which affects Bootstrap sub-theme. Patch #13 fixed the issue.
I agree with #7 and #18. But this bug present in recommended stable version since 2012 year. Please push at least this hotfix for now.
Comment #35
jonbim CreditAttribution: jonbim commentedThanks for the patch #13 - this fixed it for us. We can confirm this causes a lot of problems with Omega, including breaking the theme after changes are made through admin (eg saving a content type) - it was also intermittently intercepting saving changes via views.
Comment #36
sonicthoughts CreditAttribution: sonicthoughts as a volunteer commentedBREAKS Bootstrap. PLEASE release hotfix with this patch! FYI - only using this module for mandrill support. Patch #13 fixes it. Note that this is a pretty hard bug to track down.
Comment #37
gaele CreditAttribution: gaele commentedBerdir should have a look at it before commit. See #27 and #25.
Comment #38
Angry Dan CreditAttribution: Angry Dan at Deeson commentedI'm having the same problems, but with the Bootstrap theme. I know it's a hack and putting it in a stable release channel feels wrong, but it's definitely worse when your sites primary theme blows up (really badly).
I've patched my site and it fixes the the problem for me. I'd recommend marking this issue "Needs work" but also committing the patch in #13 and releasing as soon as possible.
Comment #39
sonicthoughts CreditAttribution: sonicthoughts as a volunteer commented@angry-dan - completely agree. The patch may not be elegant but IMO a mysterious broken theme due to mail is far worse.
Comment #40
kplanz CreditAttribution: kplanz at Bright Solutions GmbH commentedWe had the issue that our omega-based theme broke (e.g. nearly all classes vanished from frontend markup) after the theme registry was rebuild from within the admin theme (e.g. clear all caches or add menu item).
We applied the patch from #13 and it seemed to work at first. But later we noticed that again some things vanish from the markup, like the viewport settings (from omega theme settings).
Finally we found out that there is a much simpler solution than the patch from #13. Simply calling
cache_clear_all('theme_registry', 'cache', TRUE);
resolved all our issues. I have attached the change as a patch.Comment #41
abarpetia CreditAttribution: abarpetia commentedHello,
I can confirm that provided patch in #40 worked for me.
Thank you,
abarpetia
Comment #42
elioshA duplicate of this issue was in bootstrap theme (https://www.drupal.org/node/2615978)
I can confirm that #13 works for that issue, and 40 does not work.
Thanks to all for your work and availability !
Comment #43
bserem CreditAttribution: bserem commented@eliosh did you applied the patch against latest dev or against 7.x-2.34 (which is almost 4 years old) ?
I had no luck applying #13 or #40 against 7.x-2.x-dev.
Comment #44
oriol_e9gI have the same problem with a bootstrap subtheme, so I have created manually a new patch based in #13 with the last 7.x-2.x-dev version.
This patch cleanly apply and works.
Patch in #40 doesn't solve the problem, maybe this is related with another bug.
Comment #46
TwoDThe patch in #44 works great for us!
Just a nitpick about a trailing tab. ;)
Comment #48
robcarrI've re-rolled patch at #44 to remove the offending white space. Hopefully it will pass testing now.
Comment #50
DamienMcKennaThe tests failed with the response "No valid tests were specified" because of a bug in DrupalCI: #2645590: Ensure that simpletest job doesn't "fail" testing if no tests are present
Comment #51
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedThe patch in #48 works great for us, thank you very much!
Comment #53
oriol_e9gComment #54
BerdirNot really maintaining the 7.x branches but looks like nobody else is either ;)
Code looks pretty scary but has been tested by lots of people, so, committed to 7.x-2.x.
Comment #57
xaris.tsimpouris CreditAttribution: xaris.tsimpouris as a volunteer commentedSuch a wierd bug. Tested on currently 7.x-2.x-dev version and issue is fixed - no clear cache is needed now.
Comment #58
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commentedGreat! Would it be possible to have a new official release including this fix please?
Thank you!
Comment #59
jmary CreditAttribution: jmary as a volunteer and commentedThe patch at #40 shouldn't be used as the impact on performance is crazy. (Can be made worse though at clearing all the cache)
Using Omega 4.4, things are fine again at simply using the dev version at that date.
This said, having a bug in the theme layout, where the cause is to be found in the mailsystem module, is very very nasty.
Thanks to the bkonetzny who spend time going to debug that.
Comment #60
wesleymusgrove CreditAttribution: wesleymusgrove commentedConfirming that the patch in #44 solves the issue.
See my comment #11 on #2637832: Undefined function bootstrap_setting() for a full explanation of my testing and reproduction procedures.
Comment #61
attiks CreditAttribution: attiks at Attiks commentedChased this bug for too long as well, any change we can get a new release, #2692985: Create a new stable release of 7.x-2.x is marked RTBC
Comment #62
Skeptimom CreditAttribution: Skeptimom commentedEagerly awaiting the release, thank you!!
Comment #63
candelas CreditAttribution: candelas as a volunteer commentedThanks for the work :) I wait also for the release.
Comment #64
philsward CreditAttribution: philsward commentedWhat's the deal with line 46?
This causes a rejection failure during the patch.
I'm not a patch expert, but from where I sit it's re-adding the exact same line it's supposed to remove.
Can I get some clarification on what's supposed to happen there? I just deleted the lines below 46, but after thinking about it, I'm wondering if those are supposed to be there and the failure is strictly coming from nothing being changed which means I can completely ignore the error.
Running against 2.34 stable (as opposed to dev which yes, I know has been committed to dev.)
Any help from someone with better knowledge on patches would be nice.
Comment #65
Tom Verhaeghe CreditAttribution: Tom Verhaeghe as a volunteer commented#64: For some reason brackets after include_once have been added in the current stable release, and therefore the patch no longer applies. I had the same problem, so I rerolled #48 for and shared (only for your convenience ;)
Comment #66
markhalliwellRe: #46:
The reason that line is being moved (which is why it looks like it's being removed and then added back) is because if a theme relies on code from a base theme (before the base theme's
template.php
file has been loaded), it can cause a fatal. So the solution is to load the theme'stemplate.php
file after all the base themes have been loaded.Comment #67
philsward CreditAttribution: philsward commentedThanks Tom & Mark :-)
Comment #68
ezoulou CreditAttribution: ezoulou commented#66 works fine :-)
Thanks
Drupal 7.57 + Bootstrap 7.x-3.19
Comment #69
Julien Tekrane CreditAttribution: Julien Tekrane commentedToo much time spent on debuging due to an non updated module ... Thank you for the 2.35 release !