The syslog_watchdog function uses theme(), which is not a good behavior, as if the theme system is not working, no watchdog messages will be logged.
What is more, in case of drupal_not_found the current theme (like garland) cannot be changed to a $custom_theme, as the theme is already initialized by the theme call that was triggered by watchdog ► syslog_watchdog.

I've attached a D7 and D6 patch for the syslog.module.

Comments

marcingy’s picture

Status: Active » Needs review

Setting to needs review

Status: Needs review » Needs work

The last submitted patch, , failed testing.

mfb’s picture

If syslog_watchdog() is called early in bootstrap, the theme() function does not exist yet, which results in a fatal error.

In case anyone else hits this issue, this is the patch I applied to work-around the fatal error so I could access my site:

Index: modules/syslog/syslog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/syslog/syslog.module,v
retrieving revision 1.33
diff -u -p -r1.33 syslog.module
--- modules/syslog/syslog.module	27 Jan 2010 11:29:51 -0000	1.33
+++ modules/syslog/syslog.module	29 Mar 2010 19:07:15 -0000
@@ -80,7 +80,9 @@ function syslog_watchdog(array $log_entr
     openlog('drupal', LOG_NDELAY, variable_get('syslog_facility', $default_facility));
   }
 
-  syslog($log_entry['severity'], theme('syslog_format', array('entry' => $log_entry)));
+  $variables = array('entry' => $log_entry);
+  $message = function_exists('theme') ? theme('syslog_format', $variables) : theme_syslog_format($variables);
+  syslog($log_entry['severity'], $message);
 }
 
 /**
mfb’s picture

One thing about syslog-d7-theme.patch: If syslog_watchdog is called early in bootstrap, we have the same problem with drupal_alter() as with theme(): the function is not yet defined.

mfb’s picture

Here's the fatal error for anyone experiencing errors/warnings during bootstrap and using syslog: PHP Fatal error: Call to undefined function theme() in /modules/syslog/syslog.module on line 83

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.62 KB

Removed drupal_alter() so syslog works in early bootstrap. Also changed the tokens to use "!" rather than "%" to match those in plain-text e-mails (the variables are not HTML-encoded).

moshe weitzman’s picture

Looks reasonable to me. Would be good to get another pair of eyes.

mfb’s picture

StatusFileSize
new4.33 KB
JacobSingh’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Nice work!

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

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

JacobSingh’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (fixed) » Active

Hey, should we get a back port of this?

gábor hojtsy’s picture

Status: Active » Patch (to be ported)

Seen this bug on D6 sites as well, I agree this'd need a backport.

kenorb’s picture

The same problem during CRON run with Drupal 6.20
Cron shouldn't init theme functions.

But:
drupal_cron_run() calls:
watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
which calls syslog_watchdog()
then theme('syslog_format', ) syslog.module:86
which init the whole theme by: init_theme()

The same with: drupal_cron_cleanup()
it's registered as shutdown function in common.inc (drupal_cron_run())
which cause: watchdog($type = 'cron', $message = 'Cron run exceeded the time limit and was aborted.')
and the same problem with init_theme() which is just beginning of the problems, because when doing shutdown on Apache, the whole Drupal is broken, because current path is not pointing to Drupal core, causing lots of other weird errors.

JacobSingh’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new3.67 KB

Here is a D6 version of the same. Of course there is no backwards compatibility for people using the theme() call, but it's still worthwhile.

Status: Needs review » Needs work

The last submitted patch, syslog_format.patch, failed testing.

anusornwebsite’s picture

Title: syslog_watchdog() using theme() » Warning: openlog() has been disabled for security reasons in syslog_watchdog() (line 94 of /modules/syslog/syslog.module).
Version: 6.x-dev » 7.0
Assigned: Unassigned » anusornwebsite
Priority: Normal » Major

Warning: openlog() has been disabled for security reasons in syslog_watchdog() (line 94 of /home/name/domains/sitename.com/public_html/modules/syslog/syslog.module). This is my problem that show me when I just installed and enable Syslog module.

bfroehle’s picture

Title: Warning: openlog() has been disabled for security reasons in syslog_watchdog() (line 94 of /modules/syslog/syslog.module). » syslog_watchdog() using theme()
Version: 7.0 » 6.x-dev
Assigned: anusornwebsite » Unassigned
Priority: Major » Normal

@anusornwebsite: Please do not hijack existing issues for new bugs. Instead, please file a new issue. Thanks.

anusornwebsite’s picture

Status: Needs work » Needs review

syslog-d7-theme.patch queued for re-testing.

omerida’s picture

patch #16 worked for me but I had to do patch < syslog_format_0.patch for it to apply.

bkalbs’s picture

StatusFileSize
new3.72 KB

Here is an updated patch that should apply this

Status: Needs review » Needs work

The last submitted patch, syslog_theme.patch, failed testing.

omerida’s picture

StatusFileSize
new3.69 KB

patch attempt

omerida’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, syslog_theme.patch, failed testing.

oranjer’s picture

Hi All

After i change my hosting and update my database everything seem to work properly but there some error occur here :

warning: openlog() has been disabled for security reasons in /home/user/domains/mysite.com/public_html/modules/syslog/syslog.module on line 83.
warning: strtr() [function.strtr]: The second argument is not an array in /home/user/domains/mysite.com/public_html/modules/syslog/syslog.module on line 113.

any idea ?
Thank in advance

Oranjer

bfroehle’s picture

oranjer: disable the syslog module.

oranjer’s picture

thank you bfroehle

I will do as your advice.

regards
Oranjer

digi24’s picture

I do not understand #22 and #24. Are they made just the wrong way (new->old), or is there something different inside the logic.

Logic from #16 works for me.

donquixote’s picture

subscribe.

donquixote’s picture

this also lets the block administration page (admin/build/block) fail to switch theme.
(just to mention it)

anavarre’s picture

Subscribe

catch’s picture

Version: 6.x-dev » 8.x-dev
Priority: Normal » Major

This is broken enough it should be major.

dave reid’s picture

Version: 8.x-dev » 6.x-dev
Priority: Major » Normal

Huh? This has already been fixed in 7.x and above in http://drupal.org/node/659784#comment-2871880. This is about backporting this to 6.x now.

catch’s picture

Priority: Normal » Major

Doh, this is a backport, but I got very confused by the hijacking.

xjm’s picture

Title: syslog_watchdog() using theme() » (D6 backport) syslog_watchdog() using theme()

Maybe adding to the title will help prevent the same confusion. :)

pklns’s picture

Status: Needs work » Needs review

syslog-d6-theme.patch queued for re-testing.

catch’s picture

StatusFileSize
new3.69 KB

This is a straight re-roll of Jacob's patch in #16 (subsequent patches were reverts for some reason), just for the git migration.

Also marking RTBC.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Actually marking RTBC this time.

fitzherbert caruthers’s picture

syslog-d7-theme.patch queued for re-testing.

ryan.ryan’s picture

Worked for me. Seems like this is RTBC!

kenorb’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
scor’s picture

Issue summary: View changes
Status: Patch (to be ported) » Reviewed & tested by the community

not sure why this was switched to needs backport

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 39: syslog_format_D6.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.