From e8306706e85eff6f208997f6affda813aacedcc1 Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Fri, 9 Mar 2007 02:04:36 +0000 Subject: [PATCH] dumpBackup should instantiate correct database class for db type add set_timeout() method to Database --- includes/Database.php | 5 +++++ includes/DatabasePostgres.php | 3 +++ maintenance/backup.inc | 9 +++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index d51553f8d2..96dcc1b02b 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1967,6 +1967,11 @@ class Database { return $b; } + function set_timeout($timeout) { + $this->query( "SET net_read_timeout=$timeout" ); + $this->query( "SET net_write_timeout=$timeout" ); + } + /** * Read and execute SQL commands from a file. * Returns true on success, error string on failure diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index e479a6a8db..b55cbc1fc7 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -937,6 +937,9 @@ class DatabasePostgres extends Database { return array( $startOpts, $useIndex, $tailOpts ); } + function set_timeout($timeout) { + } + function ping() { wfDebug( "Function ping() not written for DatabasePostgres.php yet"); return true; diff --git a/maintenance/backup.inc b/maintenance/backup.inc index 2c3ce6bb4d..b770c5c61e 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -216,12 +216,13 @@ class BackupDumper { function &backupDb() { global $wgDBadminuser, $wgDBadminpassword; - global $wgDBname, $wgDebugDumpSql; + global $wgDBname, $wgDebugDumpSql, $wgDBtype; $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack - $db = new Database( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags ); + + $class = 'Database' . ucfirst($wgDBtype); + $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags ); $timeout = 3600 * 24; - $db->query( "SET net_read_timeout=$timeout" ); - $db->query( "SET net_write_timeout=$timeout" ); + $db->set_timeout($timeout); return $db; } -- 2.20.1