- public function postSendUpdates() {
- try {
- JobQueueGroup::pushLazyJobs();
- $this->triggerJobs();
- $this->restInPeace();
- } catch ( Exception $e ) {
- MWExceptionHandler::handleException( $e );
+ public function doPostOutputShutdown( $mode = 'normal' ) {
+ // Show profiling data if enabled
+ Profiler::instance()->logDataPageOutputOnly();
+
+ $that = $this;
+ $callback = function () use ( $that, $mode ) {
+ try {
+ // Assure deferred updates are not in the main transaction
+ wfGetLBFactory()->commitMasterChanges();
+ // Run jobs occasionally, if enabled
+ if ( $mode === 'normal' ) {
+ $that->triggerJobs();
+ }
+ // Do deferred updates and job insertion and final commit
+ $that->restInPeace();
+ } catch ( Exception $e ) {
+ MWExceptionHandler::handleException( $e );
+ }
+ };
+
+ if ( function_exists( 'register_postsend_function' ) ) {
+ // https://github.com/facebook/hhvm/issues/1230
+ register_postsend_function( $callback );
+ } else {
+ if ( function_exists( 'fastcgi_finish_request' ) ) {
+ fastcgi_finish_request();
+ } else {
+ // Either all DB and deferred updates should happen or none.
+ // The later should not be cancelled due to client disconnect.
+ ignore_user_abort( true );
+ }
+
+ $callback();