summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-26 14:11:38 +0000
committerGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-26 14:11:38 +0000
commit53d16d7da0a45de7164a3ba5147fb7864be17531 (patch)
tree3f1748b77a2c7db39c7b092bc74057ea9c1fadc8 /includes
parente6c9ae9889f249a9531b9936ed4c04680f26c9b3 (diff)
downloadbrdo-53d16d7da0a45de7164a3ba5147fb7864be17531.tar.gz
brdo-53d16d7da0a45de7164a3ba5147fb7864be17531.tar.bz2
#42000, Watchdog can't log errors when using db_set_active(non-default), patch by Chris Johnson and myself
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc7
-rw-r--r--includes/database.inc9
2 files changed, 14 insertions, 2 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 05b172bea..0728aaf8c 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -590,7 +590,14 @@ function request_uri() {
*/
function watchdog($type, $message, $severity = WATCHDOG_NOTICE, $link = NULL) {
global $user;
+
+ $current_db = db_set_active();
+
db_query("INSERT INTO {watchdog} (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (%d, '%s', '%s', %d, '%s', '%s', '%s', '%s', %d)", $user->uid, $type, $message, $severity, $link, request_uri(), referer_uri(), $_SERVER['REMOTE_ADDR'], time());
+
+ if ($current_db) {
+ db_set_active($current_db);
+ }
}
/**
diff --git a/includes/database.inc b/includes/database.inc
index 5d58feff9..d2992dc8b 100644
--- a/includes/database.inc
+++ b/includes/database.inc
@@ -95,6 +95,8 @@ function db_prefix_tables($sql) {
* @param $name
* The name assigned to the newly active database connection. If omitted, the
* default connection will be made active.
+ *
+ * @return the name of the
*/
function db_set_active($name = 'default') {
global $db_url, $db_type, $active_db;
@@ -110,7 +112,7 @@ function db_set_active($name = 'default') {
}
$db_type = substr($connect_url, 0, strpos($connect_url, '://'));
- $handler = "./includes/database.$db_type.inc";
+ $handler = "./includes/database.$db_type.inc";
if (is_file($handler)) {
include_once $handler;
@@ -124,10 +126,13 @@ function db_set_active($name = 'default') {
}
$db_conns[$name] = db_connect($connect_url);
-
}
+
+ $previous_db = $active_db;
// Set the active connection.
$active_db = $db_conns[$name];
+
+ return array_search($previousdb, $db_conns);
}
/**