Call to undefined function _simplenews_template_message()

jshuster@drupal.org - March 6, 2009 - 16:50
Project:Simplenews Template
Version:5.x-1.4
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

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!

AttachmentSize
simplenews_template.module.patch550 bytes

#1

hanoii - March 12, 2009 - 14:14

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.

AttachmentSize
simplenews_template.module.patch 779 bytes

#2

hanoii - March 12, 2009 - 14:15
Status:active» needs work

#3

hanoii - March 12, 2009 - 14:15
Status:needs work» needs review

#4

arvana - March 25, 2009 - 17:30

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!!!

#5

z.stolar - March 26, 2009 - 13:06
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.

#6

hanoii - May 8, 2009 - 14:14

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.

#7

Quinti - May 13, 2009 - 21:56

is a very important error...,

none of the patches runs for me...

greetings

#8

billyjp - June 16, 2009 - 07:25

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.

#9

nofue - June 17, 2009 - 17:10

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.

#10

billyjp - June 18, 2009 - 11:45

Can anyone discribe how i install this patchfile!

Thank you.

#11

hanoii - June 18, 2009 - 15:00

#12

AppleBag - July 2, 2009 - 06:09

Worked great!

#13

nofue - July 13, 2009 - 15:17

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

#14

viktor.mastoridis - July 31, 2009 - 23:54

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

#15

ngaur - August 2, 2009 - 19:06

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?

#16

RXM307 - September 9, 2009 - 05:54

Yes Can this please be released in the near future?

#17

hanoii - September 29, 2009 - 18:01
Status:reviewed & tested by the community» fixed

Patch #2 Commited.

#18

System Message - October 13, 2009 - 18:10
Status:fixed» closed

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

#19

philippejadin - November 3, 2009 - 13:22

+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.

 
 

Drupal is a registered trademark of Dries Buytaert.