From 3caa998c8c9b7b80b43c60b0bdffb68fa1f05660 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 9 Mar 2007 15:26:41 +0000 Subject: [PATCH] prettify: * set_timeout() -> setTimeout() * remove a couple obsolete references from dump code --- includes/Database.php | 9 ++++++++- includes/DatabasePostgres.php | 3 ++- maintenance/backup.inc | 11 +++++++---- maintenance/dumpTextPass.php | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 96dcc1b02b..21fa09d7f7 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1967,7 +1967,14 @@ class Database { return $b; } - function set_timeout($timeout) { + /** + * Override database's default connection timeout. + * May be useful for very long batch queries such as + * full-wiki dumps, where a single query reads out + * over hours or days. + * @param int $timeout in seconds + */ + public function setTimeout( $timeout ) { $this->query( "SET net_read_timeout=$timeout" ); $this->query( "SET net_write_timeout=$timeout" ); } diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index b55cbc1fc7..68f2e02c69 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -937,7 +937,8 @@ class DatabasePostgres extends Database { return array( $startOpts, $useIndex, $tailOpts ); } - function set_timeout($timeout) { + public function setTimeout( $timeout ) { + /// @fixme no-op } function ping() { diff --git a/maintenance/backup.inc b/maintenance/backup.inc index b770c5c61e..ee44954ca4 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -174,7 +174,7 @@ class BackupDumper { $this->initProgress( $history ); - $db =& $this->backupDb(); + $db = $this->backupDb(); $exporter = new WikiExporter( $db, $history, WikiExporter::STREAM, $text ); $wrapper = new ExportProgressFilter( $this->sink, $this ); @@ -214,15 +214,18 @@ class BackupDumper { $this->startTime = wfTime(); } - function &backupDb() { + function backupDb() { global $wgDBadminuser, $wgDBadminpassword; global $wgDBname, $wgDebugDumpSql, $wgDBtype; $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack $class = 'Database' . ucfirst($wgDBtype); $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags ); - $timeout = 3600 * 24; - $db->set_timeout($timeout); + + // Discourage the server from disconnecting us if it takes a long time + // to read out the big ol' batch query. + $db->setTimeout( 3600 * 24 ); + return $db; } diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index ffbfd4eb74..494c5ad4fc 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -116,7 +116,7 @@ class TextPassDumper extends BackupDumper { $this->initProgress( $this->history ); - $this->db =& $this->backupDb(); + $this->db = $this->backupDb(); $this->egress = new ExportProgressFilter( $this->sink, $this ); -- 2.20.1