r20290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20289‎ | r20290 | r20291 >
Date:15:26, 9 March 2007
Author:brion
Status:old
Tags:
Comment:
prettify:
* set_timeout() -> setTimeout()
* remove a couple obsolete references from dump code
Modified paths:
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/maintenance/backup.inc (modified) (history)
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/backup.inc
@@ -174,7 +174,7 @@
175175
176176 $this->initProgress( $history );
177177
178 - $db =& $this->backupDb();
 178+ $db = $this->backupDb();
179179 $exporter = new WikiExporter( $db, $history, WikiExporter::STREAM, $text );
180180
181181 $wrapper = new ExportProgressFilter( $this->sink, $this );
@@ -214,15 +214,18 @@
215215 $this->startTime = wfTime();
216216 }
217217
218 - function &backupDb() {
 218+ function backupDb() {
219219 global $wgDBadminuser, $wgDBadminpassword;
220220 global $wgDBname, $wgDebugDumpSql, $wgDBtype;
221221 $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack
222222
223223 $class = 'Database' . ucfirst($wgDBtype);
224224 $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags );
225 - $timeout = 3600 * 24;
226 - $db->set_timeout($timeout);
 225+
 226+ // Discourage the server from disconnecting us if it takes a long time
 227+ // to read out the big ol' batch query.
 228+ $db->setTimeout( 3600 * 24 );
 229+
227230 return $db;
228231 }
229232
Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -116,7 +116,7 @@
117117
118118 $this->initProgress( $this->history );
119119
120 - $this->db =& $this->backupDb();
 120+ $this->db = $this->backupDb();
121121
122122 $this->egress = new ExportProgressFilter( $this->sink, $this );
123123
Index: trunk/phase3/includes/DatabasePostgres.php
@@ -937,7 +937,8 @@
938938 return array( $startOpts, $useIndex, $tailOpts );
939939 }
940940
941 - function set_timeout($timeout) {
 941+ public function setTimeout( $timeout ) {
 942+ /// @fixme no-op
942943 }
943944
944945 function ping() {
Index: trunk/phase3/includes/Database.php
@@ -1967,7 +1967,14 @@
19681968 return $b;
19691969 }
19701970
1971 - function set_timeout($timeout) {
 1971+ /**
 1972+ * Override database's default connection timeout.
 1973+ * May be useful for very long batch queries such as
 1974+ * full-wiki dumps, where a single query reads out
 1975+ * over hours or days.
 1976+ * @param int $timeout in seconds
 1977+ */
 1978+ public function setTimeout( $timeout ) {
19721979 $this->query( "SET net_read_timeout=$timeout" );
19731980 $this->query( "SET net_write_timeout=$timeout" );
19741981 }