Index: trunk/phase3/maintenance/backup.inc |
— | — | @@ -232,28 +232,26 @@ |
233 | 233 | $this->startTime = wfTime(); |
234 | 234 | } |
235 | 235 | |
| 236 | + /** |
| 237 | + * @fixme the --server parameter is currently not respected, as it doesn't seem |
| 238 | + * terribly easy to ask the load balancer for a particular connection by name. |
| 239 | + */ |
236 | 240 | function backupDb() { |
237 | | - global $wgDBadminuser, $wgDBadminpassword; |
238 | | - global $wgDBuser, $wgDBpassword; |
239 | | - global $wgDBname, $wgDebugDumpSql, $wgDBtype; |
240 | | - $flags = ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT; // god-damn hack |
| 241 | + $this->lb = wfGetLBFactory()->newMainLB(); |
| 242 | + $db = $this->lb->getConnection( DB_SLAVE, 'backup' ); |
241 | 243 | |
242 | | - if ( !$wgDBadminuser ) { |
243 | | - $wgDBadminuser = $wgDBuser; |
244 | | - } |
245 | | - if ( !$wgDBadminpassword ) { |
246 | | - $wgDBadminpassword = $wgDBpassword; |
247 | | - } |
248 | | - |
249 | | - $class = 'Database' . ucfirst($wgDBtype); |
250 | | - $db = new $class( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname, false, $flags ); |
251 | | - |
252 | 244 | // Discourage the server from disconnecting us if it takes a long time |
253 | 245 | // to read out the big ol' batch query. |
254 | 246 | $db->setTimeout( 3600 * 24 ); |
255 | 247 | |
256 | 248 | return $db; |
257 | 249 | } |
| 250 | + |
| 251 | + function __destruct() { |
| 252 | + if( isset( $this->lb ) ) { |
| 253 | + $this->lb->closeAll(); |
| 254 | + } |
| 255 | + } |
258 | 256 | |
259 | 257 | function backupServer() { |
260 | 258 | global $wgDBserver; |