We have a module that sends an email message as part of cron, using Mimemail. When cron runs, we get this error:

Call to undefined function _simplenews_template_message() in ../sites/all/modules/simplenews_template/simplenews_template.module on line 183

The call sequence is this:

our code -> mimemail() -> mimemail_prepare() -> theme_mimemail_message() -> phptemplate_mimemail_message()

... which tries to call _simplenews_template_message(). Since phptemplate_mimemail_message() was called from outside Simplenews Template, _simplenews_template_message() hasn't been loaded yet, and this triggers the error.

I did a quick fix, by testing for the existence of _simplenews_template_message() before calling it. I've attached this as a patch. This lets our email message through, and I presume this lets simplenews_template do what it needs to do.

However, I'm not sure this this is the best way to fix this ... any suggestions?

Let me know how I can help ... and nice module, BTW!

Comments

hanoii’s picture

StatusFileSize
new779 bytes

Same problem here on a similar scenario, although I think the first patch needs work because it's bypassing what simplenews_template does. The problem is that on cron run, an inclusion file is not properly included. I have attach a patch that include the missing file before calling functions on that file.

I do have a question. I have seen this in many modules and I am wondering why this is a common practice. I understand the need of cleaning up the code a little bit by putting functions inside include files, however, I feel it's better if the include file is included at the beginning of the module's file than on each function that requires a function from that file. I think this approach is less error-prone in terms of forgetting to include a file when it's actually needed.

Anyway, patch attached.

hanoii’s picture

Status: Active » Needs work
hanoii’s picture

Status: Needs work » Needs review
ob3ron’s picture

I was getting the same error on submission of the site's contact form with simplenews_template installed. Hanoii's patch worked for me -- thanks!!!

z.stolar’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

This is a critical bug as it causes white screen of death in certain configurations.
The patch at #2 fixes the problem.

hanoii’s picture

Bumping up this issue. I just noticed that there's more scenarios, not only cron run, when the site throws up this fatal error. My patch at #1 fixed that as well.

quinti’s picture

is a very important error...,

none of the patches runs for me...

greetings

billyjp’s picture

Hi!

Have the same error "Fatal error: Call to undefined function _simplenews_template_message() in /var/www/pomberger/htdocs/pomberger/sites/all/modules/simplenews_template/simplenews_template.module on line 183"

How can i use the patch? Copy it over the simplenews_template.module?

Thanks for your help.

nofue’s picture

Me too -- sending a message through the contact form, users get the wsod. Would be great if there were a patched (dev) version for dl, as patching modules isn't exactly my best skill :) TIA.

billyjp’s picture

Can anyone discribe how i install this patchfile!

Thank you.

hanoii’s picture

AppleBag’s picture

Worked great!

nofue’s picture

Hanoii, thanks for the patch and the link to the manual. Worked perfectly well for me.

viktor.mastoridis’s picture

Thanks a lot. Hanoli's patch worked for me.

ngaur’s picture

Thanks for the patch hanoi.

I'm a bit concerned at how long this has gone unpatched in the module source. Can we please have a fixed release?

RXM307’s picture

Yes Can this please be released in the near future?

hanoii’s picture

Status: Reviewed & tested by the community » Fixed

Patch #2 Commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

philippejadin’s picture

+1 for a release with this fix.

It's critical as it disalow people to subscribe and has a lot of other nasty effects. For example on our site, when people add content, a mail is sent. Without the patch, anonymous users cannot contribute to the site anymore.