Hi @all,

I just found a wrong usage of the severity argument in a watchdog call in the system.module:

Line 1245

watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->filepath), 'error');

should be:

watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->filepath), WATCHDOG_ERROR);

Cheers

hctom

CommentFileSizeAuthor
#7 WATCHDOG_ERROR-7.x.patch865 byteslilou

Comments

samirnassar’s picture

If the error is confirmed I can provide a patch.

hctom’s picture

... while stepping through the source, I found some other strange watchdog calls:

system.module on line 1675:

watchdog('error', 'Cannot use %author token in this context.');

I'm not sure if this is really a task to solve, but "error" is not really a got error type, isn't it? :-)

Same thing on line 1709 in system.module:

watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));

Cheers

hctom

Anonymous’s picture

Priority: Normal » Critical

WATCHDOG_ERROR and 'error' are definitely not the same thing. The watchdog function is a hook wrapper so it depends on what system_watchdog does with it. In reviewing the api.drupal.org for this I see that the hook_watchdog example is incorrect, a) it should use watchdog_severity_levels instead of setting its own array and b) it use a variable $log instead of the $log_msg parameter that was passed to it when setting the $subject variable.

WATCHDOG_ERROR is what should be used for the severity. The lines pointed out in #2 are questionable but not necessarily wrong. I would rather see a more meaningful watchdog type than 'error' though.

This is critical because causing PHP errors while trying to log errors isn't a very good idea.

hctom’s picture

Hi @all,

here is another addition to the documentation issues mentioned by earnie. The following example line is also written with wrong arguments:

drupal_mail('emaillog', $to, $subject, $body, $from = NULL, $headers = array());

This seems to be the Drupal 5 way to send an email. In Drupal 6, the first argument has to be the module which then is followed by the mail key and also the language is missing etc. Here is the Drupal 6 function signature to compare:

drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE)

Cheers

hctom

Anonymous’s picture

@hctom: I'm thinking the documentation patch needs a new issue. The documentation for the hook system is found in CVS under contributions/docs/developer. This issue can contain the patch for the system module.

hctom’s picture

@earnie: unfortunately I cannot create patches as I cannot install a CVS client on my system :( Is there any other possibility to help making this happen?

Cheers

hctom

lilou’s picture

Title: Wrong usage of watchdog severity on line 1241 » Wrong usage of watchdog severity
Version: 6.2 » 7.x-dev
Status: Active » Needs review
StatusFileSize
new865 bytes
pasqualle’s picture

Status: Needs review » Reviewed & tested by the community

this should work

webchick’s picture

Status: Reviewed & tested by the community » Fixed

I committed the patch in #7. If we could get separate issues to discuss the other items raised here, that'd be cool. :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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