Commit 64b100d1 authored by Dries's avatar Dries

- Patch #13260 by UnConeD: watchdog module improvements.

  We added a 'severity' column to watchdog():
    watchdog($type, $message, $link) --> watchdog($type, $message, $severity, $link);

    * Specify a severity in case you are reporting a warning or error.
    * The $link-parameter is now the fourth parameter instead of the third.

  TODO: document this in the upgrade guide.
parent 0830efe9
......@@ -16,7 +16,7 @@
// Check if the last cron run completed
if (variable_get('cron_busy', false)) {
watchdog('cron', t('Last cron run did not complete.'));
watchdog('cron', t('Last cron run did not complete.'), WATCHDOG_WARNING);
}
else {
variable_set('cron_busy', true);
......
......@@ -750,6 +750,7 @@ CREATE TABLE watchdog (
uid integer NOT NULL default '0',
type varchar(16) NOT NULL default '',
message text NOT NULL default '',
severity smallint NOT NULL default '0',
link varchar(255) NOT NULL default '',
location varchar(128) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
......
......@@ -90,7 +90,8 @@
"2004-11-07" => "update_111",
"2004-11-15" => "update_112",
"2004-11-28" => "update_113",
"2004-12-05" => "update_114"
"2004-12-05" => "update_114",
"2005-01-07" => "update_115"
);
function update_32() {
......@@ -2066,6 +2067,17 @@ function update_114() {
return $ret;
}
function update_115() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {watchdog} ADD severity tinyint(3) unsigned NOT NULL default '0'");
}
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql("ALTER TABLE {watchdog} ADD severity smallint NOT NULL default '0'");
}
return $ret;
}
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
......
......@@ -9,6 +9,11 @@
define('CACHE_PERMANENT', 0);
define('CACHE_TEMPORARY', -1);
define('WATCHDOG_NOTICE', 0);
define('WATCHDOG_WARNING', 1);
define('WATCHDOG_ERROR', 2);
/**
* Locate the appropriate configuration file.
*
......@@ -574,12 +579,17 @@ function timer_start() {
* The category to which this message belongs.
* @param $message
* The message to store in the log.
* @param $severity
* The severity of the message. One of the following values:
* - WATCHDOG_NOTICE
* - WATCHDOG_WARNING
* - WATCHDOG_ERROR
* @param $link
* A link to associate with the message.
*/
function watchdog($type, $message, $link = NULL) {
function watchdog($type, $message, $severity = WATCHDOG_NOTICE, $link = NULL) {
global $user;
db_query("INSERT INTO {watchdog} (uid, type, message, link, location, hostname, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $user->uid, $type, $message, $link, request_uri(), $_SERVER['REMOTE_ADDR'], time());
db_query("INSERT INTO {watchdog} (uid, type, message, severity, link, location, hostname, timestamp) VALUES (%d, '%s', '%s', %d, '%s', '%s', '%s', %d)", $user->uid, $type, $message, $severity, $link, request_uri(), $_SERVER['REMOTE_ADDR'], time());
}
/**
......
......@@ -166,7 +166,7 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL) {
*/
function drupal_not_found() {
header('HTTP/1.0 404 Not Found');
watchdog('page not found', t('%page not found.', array('%page' => '<em>'. db_escape_string($_GET['q']) .'</em>')));
watchdog('page not found', t('%page not found.', array('%page' => '<em>'. db_escape_string($_GET['q']) .'</em>')), WATCHDOG_WARNING);
$path = drupal_get_normal_path(variable_get('site_404', ''));
$status = MENU_NOT_FOUND;
......@@ -186,7 +186,7 @@ function drupal_not_found() {
*/
function drupal_access_denied() {
header('HTTP/1.0 403 Forbidden');
watchdog('access denied', t('%page denied access.', array('%page' => '<em>'. db_escape_string($_GET['q']) .'</em>')));
watchdog('access denied', t('%page denied access.', array('%page' => '<em>'. db_escape_string($_GET['q']) .'</em>')), WATCHDOG_WARNING);
$path = drupal_get_normal_path(variable_get('site_403', ''));
$status = MENU_NOT_FOUND;
......@@ -342,11 +342,11 @@ function error_handler($errno, $message, $filename, $line, $variables) {
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
$entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
watchdog('error', t('%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line)));
if (variable_get('error_level', 1) == 1) {
print '<pre>'. $entry .'</pre>';
}
watchdog('php', t('%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line)), WATCHDOG_ERROR);
}
}
......@@ -602,7 +602,7 @@ function valid_input_data($data) {
$match += preg_match("/<\s*(applet|script|object|style|embed|form|blink|meta|html|frame|iframe|layer|ilayer|head|frameset|xml)/i", $data);
if ($match) {
watchdog('warning', t('Terminated request because of suspicious input data: %data.', array('%data' => '<em>'. drupal_specialchars($data) .'</em>')));
watchdog('security', t('Terminated request because of suspicious input data: %data.', array('%data' => '<em>'. drupal_specialchars($data) .'</em>')));
return FALSE;
}
}
......@@ -1597,7 +1597,7 @@ function drupal_xml_parser_create(&$data) {
$out = @recode_string($encoding . '..utf-8', $data);
}
else {
watchdog('warning', t("Unsupported XML encoding '%s'. Please install iconv, GNU recode or mbstring for PHP.", $encoding));
watchdog('php', t("Unsupported XML encoding '%s'. Please install iconv, GNU recode or mbstring for PHP.", $encoding), WATCHDOG_ERROR);
return 0;
}
......@@ -1606,7 +1606,7 @@ function drupal_xml_parser_create(&$data) {
$encoding = 'utf-8';
}
else {
watchdog('warning', t("Could not convert XML encoding '%s' to UTF-8.", $encoding));
watchdog('php', t("Could not convert XML encoding '%s' to UTF-8.", $encoding), WATCHDOG_WARNING);
return 0;
}
}
......
......@@ -358,7 +358,7 @@ function file_save_upload($source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
}
if (!user_access('bypass input data check') && !valid_input_data($file)) {
watchdog('error', t('Possible exploit abuse: invalid data.'));
watchdog('security', t('Possible exploit abuse: invalid data.'), WATCHDOG_WARNING);
drupal_set_message(t('File upload failed: invalid data.'), 'error');
return 0;
}
......@@ -402,7 +402,7 @@ function file_save_upload($source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
*/
function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
if (!user_access('bypass input data check') && !valid_input_data($data)) {
watchdog('error', t('Possible exploit abuse: invalid data.'));
watchdog('security', t('Possible exploit abuse: invalid data.'), WATCHDOG_WARNING);
drupal_set_message(t('File upload failed: invalid data.'), 'error');
return 0;
}
......
......@@ -30,7 +30,7 @@ function _locale_add_language($code, $name, $onlylanguage = TRUE) {
}
drupal_set_message($message);
watchdog('special', t('%language language (%locale) added.', array('%language' => "<em>$name</em>", '%locale' => "<em>$code</em>")));
watchdog('locale', t('%language language (%locale) added.', array('%language' => "<em>$name</em>", '%locale' => "<em>$code</em>")));
}
/**
......@@ -257,7 +257,7 @@ function _locale_import_po($file, $lang, $mode) {
menu_rebuild();
drupal_set_message(t('Translation successfully imported. %number translated strings added to language, %update strings updated.', array('%number' => $additions, '%update' => $updates)));
watchdog('special', t('Imported %file into %locale: %number new strings added and %update updated.', array('%file' => "<em>$file->filename</em>", '%locale' => "<em>$lang</em>", '%number' => $additions, '%update' => $updates)));
watchdog('locale', t('Imported %file into %locale: %number new strings added and %update updated.', array('%file' => "<em>$file->filename</em>", '%locale' => "<em>$lang</em>", '%number' => $additions, '%update' => $updates)));
return TRUE;
}
......@@ -768,7 +768,7 @@ function _locale_export_po($language) {
$header .= "\"Plural-Forms: nplurals=". $meta->plurals ."; plural=". strtr($meta->formula, '$', '') .";\\n\"\n";
}
$header .= "\n";
watchdog('special', t('Exported %locale translation file: %filename.', array('%locale' => "<em>$meta->name</em>", '%filename' => "<em>$filename</em>")));
watchdog('locale', t('Exported %locale translation file: %filename.', array('%locale' => "<em>$meta->name</em>", '%filename' => "<em>$filename</em>")));
}
// Generating Portable Object Template
......@@ -789,7 +789,7 @@ function _locale_export_po($language) {
$header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
$header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
$header .= "\n";
watchdog('special', t('Exported translation file: %filename.', array('%filename' => "<em>$filename</em>")));
watchdog('locale', t('Exported translation file: %filename.', array('%filename' => "<em>$filename</em>")));
}
// Start download process
......
......@@ -428,22 +428,16 @@ tr.watchdog-user {
tr.watchdog-user .active {
background: #eed;
}
tr.watchdog-special {
tr.watchdog-content {
background: #ddf;
}
tr.watchdog-special .active {
tr.watchdog-content .active {
background: #cce;
}
tr.watchdog-warning {
background: #fda;
}
tr.watchdog-warning .active {
background: #ec9;
}
tr.watchdog-httpd {
tr.watchdog-page-not-found, tr.watchdog-access-denied {
background: #dfd;
}
tr.watchdog-httpd .active {
tr.watchdog-pagenot-found .active, tr.watchdog-access-denied .active {
background: #cec;
}
tr.watchdog-error {
......
......@@ -354,7 +354,7 @@ function aggregator_refresh($feed) {
break;
case 301:
$feed['url'] = $result->redirect_url;
watchdog('special', t('Aggregator: updated URL for feed %title to %url.', array('%title' => '<em>'. $feed['title'] .'</em>', '%url' => '<em>'. $feed['url'] .'</em>')));
watchdog('aggregator', t('Updated URL for feed %title to %url.', array('%title' => '<em>'. $feed['title'] .'</em>', '%url' => '<em>'. $feed['url'] .'</em>')));
break;
case 200:
......@@ -402,13 +402,15 @@ function aggregator_refresh($feed) {
cache_clear_all();
watchdog('status', t('Aggregator: syndicated content from %site.', array('%site' => '<em>'. $feed[title] .'</em>')));
drupal_set_message(t('Syndicated content from %site.', array('%site' => '<em>'. $feed['title'] .'</em>')));
$message = t('Syndicated content from %site.', array('%site' => '<em>'. $feed[title] .'</em>'));
watchdog('aggregator', $message);
drupal_set_message($message);
}
break;
default:
watchdog('error', t('Aggregator: failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>")));
drupal_set_message(t('Failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>")));
$message = t('Failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>"));
watchdog('aggregator', $message, WATCHDOG_WARNING);
drupal_set_message($message);
}
}
......@@ -464,8 +466,9 @@ function aggregator_parse_feed(&$data, $feed) {
xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
if (!xml_parse($xml_parser, $data, 1)) {
watchdog('error', t('Aggregator: failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))));
drupal_set_message(t('Failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
$message = t('Failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)));
watchdog('aggregator', $message, WATCHDOG_WARNING);
drupal_set_message($message, 'error');
return 0;
}
xml_parser_free($xml_parser);
......
......@@ -354,7 +354,7 @@ function aggregator_refresh($feed) {
break;
case 301:
$feed['url'] = $result->redirect_url;
watchdog('special', t('Aggregator: updated URL for feed %title to %url.', array('%title' => '<em>'. $feed['title'] .'</em>', '%url' => '<em>'. $feed['url'] .'</em>')));
watchdog('aggregator', t('Updated URL for feed %title to %url.', array('%title' => '<em>'. $feed['title'] .'</em>', '%url' => '<em>'. $feed['url'] .'</em>')));
break;
case 200:
......@@ -402,13 +402,15 @@ function aggregator_refresh($feed) {
cache_clear_all();
watchdog('status', t('Aggregator: syndicated content from %site.', array('%site' => '<em>'. $feed[title] .'</em>')));
drupal_set_message(t('Syndicated content from %site.', array('%site' => '<em>'. $feed['title'] .'</em>')));
$message = t('Syndicated content from %site.', array('%site' => '<em>'. $feed[title] .'</em>'));
watchdog('aggregator', $message);
drupal_set_message($message);
}
break;
default:
watchdog('error', t('Aggregator: failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>")));
drupal_set_message(t('Failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>")));
$message = t('Failed to parse RSS feed %site: %error.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => "<em>$result->code $result->error</em>"));
watchdog('aggregator', $message, WATCHDOG_WARNING);
drupal_set_message($message);
}
}
......@@ -464,8 +466,9 @@ function aggregator_parse_feed(&$data, $feed) {
xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
if (!xml_parse($xml_parser, $data, 1)) {
watchdog('error', t('Aggregator: failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))));
drupal_set_message(t('Failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
$message = t('Failed to parse RSS feed %site: %error at line %line.', array('%site' => '<em>'. $feed['title'] .'</em>', '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)));
watchdog('aggregator', $message, WATCHDOG_WARNING);
drupal_set_message($message, 'error');
return 0;
}
xml_parser_free($xml_parser);
......
......@@ -149,7 +149,7 @@ function blogapi_new_post($req_params) {
$nid = node_save($node);
if ($nid) {
watchdog('special', t('%type: added %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
watchdog('content', t('%type: added %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval($nid, 'string'));
}
......@@ -209,7 +209,7 @@ function blogapi_edit_post($req_params) {
}
$nid = node_save($node);
if ($nid) {
watchdog('special', t('%type: updated %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
watchdog('content', t('%type: updated %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval(true, 'boolean'));
}
......
......@@ -149,7 +149,7 @@ function blogapi_new_post($req_params) {
$nid = node_save($node);
if ($nid) {
watchdog('special', t('%type: added %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
watchdog('content', t('%type: added %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval($nid, 'string'));
}
......@@ -209,7 +209,7 @@ function blogapi_edit_post($req_params) {
}
$nid = node_save($node);
if ($nid) {
watchdog('special', t('%type: updated %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
watchdog('content', t('%type: updated %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval(true, 'boolean'));
}
......
......@@ -723,7 +723,7 @@ function book_admin_save($nid, $edit = array()) {
}
$message = t('Updated book %title.', array('%title' => "<em>$book->title</em>"));
watchdog('special', $message);
watchdog('content', $message);
return $message;
}
......
......@@ -723,7 +723,7 @@ function book_admin_save($nid, $edit = array()) {
}
$message = t('Updated book %title.', array('%title' => "<em>$book->title</em>"));
watchdog('special', $message);
watchdog('content', $message);
return $message;
}
......
......@@ -520,7 +520,7 @@ function comment_post($edit) {
// validated/filtered data to perform such check.
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit['pid'], $edit['nid'], $edit['subject'], $edit['comment']), 0);
if ($duplicate != 0) {
watchdog('warning', t('Comment: duplicate %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: duplicate %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), WATCHDOG_WARNING);
}
if ($edit['cid']) {
......@@ -535,7 +535,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'update', $edit);
// Add entry to the watchdog log.
watchdog('special', t('Comment: updated %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: updated %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
else {
// Add the comment to database.
......@@ -638,7 +638,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'insert', $edit);
// Add an entry to the watchdog log.
watchdog('special', t('Comment: added %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: added %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
// Clear the cache so an anonymous user can see his comment being added.
......@@ -659,7 +659,7 @@ function comment_post($edit) {
}
}
else {
watchdog('error', t('Comment: unauthorized comment submitted or comment submitted to a closed node %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: unauthorized comment submitted or comment submitted to a closed node %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), WATCHDOG_WARNING);
}
}
......@@ -986,7 +986,7 @@ function comment_delete($cid) {
function comment_save($id, $edit) {
db_query("UPDATE {comments} SET subject = '%s', comment = '%s', status = %d, format = '%s', name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['subject'], $edit['comment'], $edit['status'], $edit['format'], $edit['name'], $edit['mail'], $edit['homepage'], $id);
watchdog('special', t('Comment: modified %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: modified %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
drupal_set_message(t('The comment has been saved.'));
}
......@@ -1614,7 +1614,7 @@ function theme_comment_post_forbidden() {
function _comment_delete_thread($comment) {
// Delete the comment:
db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
watchdog('special', t('Comment: deleted %subject.', array('%subject' => "<em>$comment->subject</em>")));
watchdog('content', t('Comment: deleted %subject.', array('%subject' => "<em>$comment->subject</em>")));
module_invoke_all('comment', 'delete', $comment);
......
......@@ -520,7 +520,7 @@ function comment_post($edit) {
// validated/filtered data to perform such check.
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit['pid'], $edit['nid'], $edit['subject'], $edit['comment']), 0);
if ($duplicate != 0) {
watchdog('warning', t('Comment: duplicate %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: duplicate %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), WATCHDOG_WARNING);
}
if ($edit['cid']) {
......@@ -535,7 +535,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'update', $edit);
// Add entry to the watchdog log.
watchdog('special', t('Comment: updated %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: updated %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
else {
// Add the comment to database.
......@@ -638,7 +638,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'insert', $edit);
// Add an entry to the watchdog log.
watchdog('special', t('Comment: added %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: added %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
// Clear the cache so an anonymous user can see his comment being added.
......@@ -659,7 +659,7 @@ function comment_post($edit) {
}
}
else {
watchdog('error', t('Comment: unauthorized comment submitted or comment submitted to a closed node %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: unauthorized comment submitted or comment submitted to a closed node %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')), WATCHDOG_WARNING);
}
}
......@@ -986,7 +986,7 @@ function comment_delete($cid) {
function comment_save($id, $edit) {
db_query("UPDATE {comments} SET subject = '%s', comment = '%s', status = %d, format = '%s', name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['subject'], $edit['comment'], $edit['status'], $edit['format'], $edit['name'], $edit['mail'], $edit['homepage'], $id);
watchdog('special', t('Comment: modified %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
watchdog('content', t('Comment: modified %subject.', array('%subject' => '<em>'. $edit['subject'] .'</em>')));
drupal_set_message(t('The comment has been saved.'));
}
......@@ -1614,7 +1614,7 @@ function theme_comment_post_forbidden() {
function _comment_delete_thread($comment) {
// Delete the comment:
db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
watchdog('special', t('Comment: deleted %subject.', array('%subject' => "<em>$comment->subject</em>")));
watchdog('content', t('Comment: deleted %subject.', array('%subject' => "<em>$comment->subject</em>")));
module_invoke_all('comment', 'delete', $comment);
......
......@@ -95,7 +95,7 @@ function drupal_directory_ping($arguments) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog('directory ping', t('ping from %name (%link).', array('%name' => "<em>$name</em>", '%link' => "<em>$link</em>")));
watchdog('directory ping', t('Ping from %name (%link).', array('%name' => "<em>$name</em>", '%link' => "<em>$link</em>")));
return new xmlrpcresp(new xmlrpcval(1, 'int'));
}
......@@ -143,7 +143,7 @@ function drupal_notify($server) {
$result = $client->send($message, 5);
if (!$result || $result->faultCode()) {
watchdog('error', t('Failed to notify %url at %path: %error.', array('%url' => '<em>'. $url["host"] .'</em>', '%path' => '<em>'. $url["path"] .'</em>', '%error' => '<em>'. $result->faultString() .'</em>')));
watchdog('directory ping', t('Failed to notify %url at %path: %error.', array('%url' => '<em>'. $url["host"] .'</em>', '%path' => '<em>'. $url["path"] .'</em>', '%error' => '<em>'. $result->faultString() .'</em>')), WATCHDOG_WARNING);
}
}
......
......@@ -95,7 +95,7 @@ function drupal_directory_ping($arguments) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog('directory ping', t('ping from %name (%link).', array('%name' => "<em>$name</em>", '%link' => "<em>$link</em>")));
watchdog('directory ping', t('Ping from %name (%link).', array('%name' => "<em>$name</em>", '%link' => "<em>$link</em>")));
return new xmlrpcresp(new xmlrpcval(1, 'int'));
}
......@@ -143,7 +143,7 @@ function drupal_notify($server) {
$result = $client->send($message, 5);
if (!$result || $result->faultCode()) {
watchdog('error', t('Failed to notify %url at %path: %error.', array('%url' => '<em>'. $url["host"] .'</em>', '%path' => '<em>'. $url["path"] .'</em>', '%error' => '<em>'. $result->faultString() .'</em>')));
watchdog('directory ping', t('Failed to notify %url at %path: %error.', array('%url' => '<em>'. $url["host"] .'</em>', '%path' => '<em>'. $url["path"] .'</em>', '%error' => '<em>'. $result->faultString() .'</em>')), WATCHDOG_WARNING);
}
}
......
......@@ -288,8 +288,9 @@ function locale_admin_manage() {
if (isset($languages['name'][$edit['langcode']])) {
db_query("DELETE FROM {locales_meta} WHERE locale = '%s'", $edit['langcode']);
db_query("DELETE FROM {locales_target} WHERE locale = '%s'", $edit['langcode']);
drupal_set_message(t('%locale language removed.', array('%locale' => '<em>'. t($languages['name'][$edit['langcode']]) .'</em>')));
watchdog('special', t('%locale language removed.', array('%locale' => '<em>'. $edit['langcode'] .'</em>')));
$message = t('%locale language removed.', array('%locale' => '<em>'. t($languages['name'][$edit['langcode']]) .'</em>'));
drupal_set_message($message);
watchdog('locale', $message);
}
// Changing the locale settings impacts the interface:
......@@ -379,7 +380,9 @@ function locale_admin_import() {
// Now import strings into the language
$file = file_check_upload('file');
if ($ret = _locale_import_po($file, $edit['langcode'], $edit['mode']) == FALSE) {
watchdog('error', t('Translation import of %filename failed.', array('%filename' => "<em>$file->filename</em>")));
$message = t('Translation import of %filename failed.', array('%filename' => "<em>$file->filename</em>"));
drupal_set_message($message, 'error');
watchdog('locale', $message, WATCHDOG_ERROR);
}
drupal_goto('admin/locale');
......
......@@ -288,8 +288,9 @@ function locale_admin_manage() {
if (isset($languages['name'][$edit['langcode']])) {
db_query("DELETE FROM {locales_meta} WHERE locale = '%s'", $edit['langcode']);
db_query("DELETE FROM {locales_target} WHERE locale = '%s'", $edit['langcode']);
drupal_set_message(t('%locale language removed.', array('%locale' => '<em>'. t($languages['name'][$edit['langcode']]) .'</em>')));
watchdog('special', t('%locale language removed.', array('%locale' => '<em>'. $edit['langcode'] .'</em>')));
$message = t('%locale language removed.', array('%locale' => '<em>'. t($languages['name'][$edit['langcode']]) .'</em>'));
drupal_set_message($message);
watchdog('locale', $message);
}
// Changing the locale settings impacts the interface:
......@@ -379,7 +380,9 @@ function locale_admin_import() {
// Now import strings into the language
$file = file_check_upload('file');
if ($ret = _locale_import_po($file, $edit['langcode'], $edit['mode']) == FALSE) {
watchdog('error', t('Translation import of %filename failed.', array('%filename' => "<em>$file->filename</em>")));
$message = t('Translation import of %filename failed.', array('%filename' => "<em>$file->filename</em>"));
drupal_set_message($message, 'error');
watchdog('locale', $message, WATCHDOG_ERROR);
}
drupal_goto('admin/locale');
......
......@@ -1400,7 +1400,7 @@ function node_submit(&$node) {
// perform this operation:
if (node_access('update', $node)) {
$node->nid = node_save($node);
watchdog('special', t('%type: updated %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), 'node/'. $node->nid));
watchdog('content', t('%type: updated %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), 'node/'. $node->nid));
$msg = t('The %post was updated.', array ('%post' => node_invoke($node, 'node_name')));
}
}
......@@ -1409,7 +1409,7 @@ function node_submit(&$node) {
// perform this operation:
if (node_access('create', $node)) {
$node->nid = node_save($node);
watchdog('special', t('%type: added %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$node->nid"));
watchdog('content', t('%type: added %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$node->nid"));
$msg = t('Your %post was created.', array ('%post' => node_invoke($node, 'node_name')));
}
}
......@@ -1444,7 +1444,7 @@ function node_delete($edit) {
search_wipe($node->nid, 'node');
}
watchdog('special', t('%type: deleted %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")));
watchdog('content', t('%type: deleted %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")));
$output = t('The node has been deleted.');
}
else {
......
......@@ -1400,7 +1400,7 @@ function node_submit(&$node) {
// perform this operation:
if (node_access('update', $node)) {
$node->nid = node_save($node);
watchdog('special', t('%type: updated %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), 'node/'. $node->nid));
watchdog('content', t('%type: updated %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), 'node/'. $node->nid));
$msg = t('The %post was updated.', array ('%post' => node_invoke($node, 'node_name')));
}
}
......@@ -1409,7 +1409,7 @@ function node_submit(&$node) {
// perform this operation:
if (node_access('create', $node)) {
$node->nid = node_save($node);
watchdog('special', t('%type: added %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$node->nid"));
watchdog('content', t('%type: added %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")), l(t('view'), "node/$node->nid"));
$msg = t('Your %post was created.', array ('%post' => node_invoke($node, 'node_name')));
}
}
......@@ -1444,7 +1444,7 @@ function node_delete($edit) {
search_wipe($node->nid, 'node');
}
watchdog('special', t('%type: deleted %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")));
watchdog('content', t('%type: deleted %title.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => "<em>$node->title</em>")));
$output = t('The node has been deleted.');
}
else {
......
......@@ -63,7 +63,7 @@ function ping_ping($name = '', $url = '') {
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog('error', t('Failed to notify pingomatic.com (site).'));
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);
}
}
......
......@@ -63,7 +63,7 @@ function ping_ping($name = '', $url = '') {
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog('error', t('Failed to notify pingomatic.com (site).'));
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);
}
}
......
......@@ -78,34 +78,34 @@ function queue_vote($node, $vote) {
$node->moderate = 0;
$node->promote = 1;
node_save($node);
watchdog('special', t('Moderation: approved %title.', array('%title' => "<em>$node->title</em>")));
watchdog('content', t('Moderation: approved %title.', array('%title' => "<em>$node->title</em>")));
drupal_set_message(t('The post is promoted.'));
}
else if (variable_get('queue_threshold_dump', -2) >= $node->score) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('Moderation: declined %title (rollback).', array('%title' => "<em>$node->title</em>")));
watchdog('content', t('Moderation: declined %title (rollback).', array('%title' => "<em>$node->title</em>")));
drupal_set_message(t('The post has been declined and the previous version has been restored.'));
}
else {
$node->moderate = 0;
$node->status = 0;
node_save($node);
watchdog('special', t('Moderation: declined %title.', array('%title' => "<em>$node->title</em>")));
watchdog('content', t('Moderation: declined %title.', array('%title' => "<em>$node->title</em>")));
drupal_set_message(t('The post has been declined.'));
}
}
else if (variable_get('queue_threshold_expire', 8) <= $node->votes) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('Moderation: expired %title (rollback).', array('%title' => "<em>$node->title</em>")));
watchdog('content', t('Moderation: expired %title (rollback).', array('%title' => "<em>$node->title</em>")));
drupal_set_message(t('The post has expired and the previous version has been restored.'));
}
else {
$node->moderate = 0;
$node->status = 0;
node_save($node);
watchdog('special', t('Moderation: expired %title.', array('%title' => "<em>$node->title</em>")));
watchdog('content', t('Moderation: expired %title.', array('%title' => "<em>$node->title</em>")));
drupal_set_message(t('The post has expired.'));
}
}
......
......@@ -936,7 +936,7 @@ function user_pass() {
drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
}
else {
watchdog('error', t('Error mailing password to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')));
watchdog('user', t('Error mailing password to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send mail. Please contact the site admin.'));
}
drupal_goto('user');
......@@ -1133,7 +1133,7 @@ function user_edit($category = 'account') {
if (!form_get_errors()) {
// Validate input to ensure that non-privileged users can't alter protected data.