/** * This function does work that can be done *after* the * user gets the HTTP response so they don't block on it * * This manages deferred updates, job insertion, * final commit, and the logging of profiling data * * @param string $mode Use 'fast' to always skip job running * @since 1.26 */ public function doPostOutputShutdown($mode = 'normal') { $timing = $this->context->getTiming(); $timing->mark('requestShutdown'); // Show visible profiling data if enabled (which cannot be post-send) Profiler::instance()->logDataPageOutputOnly(); $callback = function () use($mode) { try { $this->restInPeace($mode); } catch (Exception $e) { MWExceptionHandler::handleException($e); } }; // Defer everything else... 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 latter should not be cancelled due to client disconnect. ignore_user_abort(true); } $callback(); } }
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @author Aaron Schulz */ if (!in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '0:0:0:0:0:0:0:1', '::1'), true)) { die("Only loopback requests are allowed.\n"); } elseif ($_SERVER['REQUEST_METHOD'] !== 'POST') { die("Request must use POST.\n"); } require_once __DIR__ . '/../multiversion/MWVersion.php'; $wiki = isset($_GET['wiki']) ? $_GET['wiki'] : ''; require getMediaWiki('includes/WebStart.php', $wiki); error_reporting(E_ERROR); // fatals but not random I/O warnings ini_set('display_errors', 1); $wgShowExceptionDetails = true; if (method_exists('LBFactory', 'disableChronologyProtection')) { // This is not helpful here and will slow things down in some cases wfGetLBFactory()->disableChronologyProtection(); } try { $mediawiki = new MediaWiki(); $runner = new JobRunner(); $response = $runner->run(array('type' => isset($_GET['type']) ? $_GET['type'] : false, 'maxJobs' => isset($_GET['maxjobs']) ? $_GET['maxjobs'] : false, 'maxTime' => isset($_GET['maxtime']) ? $_GET['maxtime'] : 30)); print json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $mediawiki->restInPeace(); } catch (Exception $e) { MWExceptionHandler::handleException($e); }
/** * This function does work that can be done *after* the * user gets the HTTP response so they don't block on it * * @param string $mode Use 'fast' to always skip job running * @since 1.26 */ 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(); } }
/** * Run the current MediaWiki instance * index.php just calls this */ public function run() { try { $this->checkMaxLag(); try { $this->main(); } catch (ErrorPageError $e) { // Bug 62091: while exceptions are convenient to bubble up GUI errors, // they are not internal application faults. As with normal requests, this // should commit, print the output, do deferred updates, jobs, and profiling. wfGetLBFactory()->commitMasterChanges(); $e->report(); // display the GUI error } if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } $this->triggerJobs(); $this->restInPeace(); } catch (Exception $e) { MWExceptionHandler::handleException($e); } }