Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -321,8 +321,7 @@ |
322 | 322 | $this->context->output->output(); |
323 | 323 | // Do any deferred jobs |
324 | 324 | wfDoUpdates( 'commit' ); |
325 | | - // Close the session so that jobs don't access the current session |
326 | | - session_write_close(); |
| 325 | + |
327 | 326 | $this->doJobs(); |
328 | 327 | wfProfileOut( __METHOD__ ); |
329 | 328 | } |
— | — | @@ -345,6 +344,10 @@ |
346 | 345 | } else { |
347 | 346 | $n = intval( $wgJobRunRate ); |
348 | 347 | } |
| 348 | + |
| 349 | + // Close the session so that jobs don't access the current session |
| 350 | + $this->shutdownLBFactory(); |
| 351 | + session_write_close(); |
349 | 352 | |
350 | 353 | while ( $n-- && false != ( $job = Job::pop() ) ) { |
351 | 354 | $output = $job->toString() . "\n"; |
— | — | @@ -367,11 +370,20 @@ |
368 | 371 | public function restInPeace() { |
369 | 372 | MessageCache::logMessages(); |
370 | 373 | wfLogProfilingData(); |
| 374 | + $this->shutdownLBFactory(); |
| 375 | + wfDebug( "Request ended normally\n" ); |
| 376 | + } |
| 377 | + |
| 378 | + /** |
| 379 | + * Commit pending master changes, shutdown the current loadbalancer |
| 380 | + * factory and destroys the factory instance. |
| 381 | + */ |
| 382 | + private function shutdownLBFactory() { |
371 | 383 | // Commit and close up! |
372 | | - $factory = wfGetLBFactory(); |
| 384 | + $factory = LBFactory::singleton(); |
373 | 385 | $factory->commitMasterChanges(); |
374 | 386 | $factory->shutdown(); |
375 | | - wfDebug( "Request ended normally\n" ); |
| 387 | + LBFactory::destroyInstance(); |
376 | 388 | } |
377 | 389 | |
378 | 390 | /** |