Index: trunk/phase3/maintenance/backup.inc |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | |
176 | 176 | $this->initProgress( $history ); |
177 | 177 | |
178 | | - $db =& $this->backupDb(); |
| 178 | + $db = $this->backupDb(); |
179 | 179 | $exporter = new WikiExporter( $db, $history, WikiExporter::STREAM, $text ); |
180 | 180 | |
181 | 181 | $wrapper = new ExportProgressFilter( $this->sink, $this ); |
— | — | @@ -214,15 +214,18 @@ |
215 | 215 | $this->startTime = wfTime(); |
216 | 216 | } |
217 | 217 | |
218 | | - function &backupDb() { |
| 218 | + function backupDb() { |
219 | 219 | global $wgDBadminuser, $wgDBadminpassword; |
220 | 220 | global $wgDBname, $wgDebugDumpSql, $wgDBtype; |
221 | 221 | $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack |
222 | 222 | |
223 | 223 | $class = 'Database' . ucfirst($wgDBtype); |
224 | 224 | $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 | + |
227 | 230 | return $db; |
228 | 231 | } |
229 | 232 | |
Index: trunk/phase3/maintenance/dumpTextPass.php |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | |
118 | 118 | $this->initProgress( $this->history ); |
119 | 119 | |
120 | | - $this->db =& $this->backupDb(); |
| 120 | + $this->db = $this->backupDb(); |
121 | 121 | |
122 | 122 | $this->egress = new ExportProgressFilter( $this->sink, $this ); |
123 | 123 | |
Index: trunk/phase3/includes/DatabasePostgres.php |
— | — | @@ -937,7 +937,8 @@ |
938 | 938 | return array( $startOpts, $useIndex, $tailOpts ); |
939 | 939 | } |
940 | 940 | |
941 | | - function set_timeout($timeout) { |
| 941 | + public function setTimeout( $timeout ) { |
| 942 | + /// @fixme no-op |
942 | 943 | } |
943 | 944 | |
944 | 945 | function ping() { |
Index: trunk/phase3/includes/Database.php |
— | — | @@ -1967,7 +1967,14 @@ |
1968 | 1968 | return $b; |
1969 | 1969 | } |
1970 | 1970 | |
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 ) { |
1972 | 1979 | $this->query( "SET net_read_timeout=$timeout" ); |
1973 | 1980 | $this->query( "SET net_write_timeout=$timeout" ); |
1974 | 1981 | } |