function wfForbidden() { header('HTTP/1.0 403 Forbidden'); print "<html><body>\n<h1>Access denied</h1>\n<p>You need to log in to access files on this server</p>\n</body></html>"; wfLogProfilingData(); exit; }
public function __destruct() { // Return to real wiki db, so profiling data is preserved MediaWikiTestCase::teardownTestDB(); // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); }
function execute() { if (!file_exists('results')) { mkdir('results'); } if (!is_dir('results')) { echo "Unable to create 'results' directory\n"; exit(1); } $overallStart = microtime(true); $reportInterval = 1000; for ($i = 1; true; $i++) { $t = -microtime(true); try { self::$currentTest = new PPFuzzTest($this); self::$currentTest->execute(); $passed = 'passed'; } catch (MWException $e) { $testReport = self::$currentTest->getReport(); $exceptionReport = $e->getText(); $hash = md5($testReport); file_put_contents("results/ppft-{$hash}.in", serialize(self::$currentTest)); file_put_contents("results/ppft-{$hash}.fail", "Input:\n{$testReport}\n\nException report:\n{$exceptionReport}\n"); print "Test {$hash} failed\n"; $passed = 'failed'; } $t += microtime(true); if ($this->verbose) { printf("Test {$passed} in %.3f seconds\n", $t); print self::$currentTest->getReport(); } $reportMetric = (microtime(true) - $overallStart) / $i * $reportInterval; if ($reportMetric > 25) { if (substr($reportInterval, 0, 1) === '1') { $reportInterval /= 2; } else { $reportInterval /= 5; } } elseif ($reportMetric < 4) { if (substr($reportInterval, 0, 1) === '1') { $reportInterval *= 5; } else { $reportInterval *= 2; } } if ($i % $reportInterval == 0) { print "{$i} tests done\n"; /* $testReport = self::$currentTest->getReport(); $filename = 'results/ppft-' . md5( $testReport ) . '.pass'; file_put_contents( $filename, "Input:\n$testReport\n" );*/ } } wfLogProfilingData(); }
public function execute() { wfProfileIn(__METHOD__); //run the download: Http::doSessionIdDownload($this->getOption('sid'), $this->getOption('usk')); // close up shop: // Execute any deferred updates wfDoUpdates(); // Log what the user did, for book-keeping purposes. wfLogProfilingData(); // Shut down the database before exit wfGetLBFactory()->shutdown(); wfProfileOut(__METHOD__); }
public function run(array $argv, $exit = true) { wfProfileIn(__METHOD__); $ret = parent::run($argv, false); wfProfileOut(__METHOD__); // Return to real wiki db, so profiling data is preserved MediaWikiTestCase::teardownTestDB(); // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); if ($exit) { exit($ret); } else { return $ret; } }
/** * Issue a standard HTTP 403 Forbidden header and a basic * error message, then end the script */ function wfForbidden() { header('HTTP/1.0 403 Forbidden'); header('Vary: Cookie'); header('Content-Type: text/html; charset=utf-8'); echo <<<ENDS <html> <body> <h1>Access Denied</h1> <p>You need to log in to access files on this server.</p> </body> </html> ENDS; wfLogProfilingData(); exit; }
/** * Exception handler which simulates the appropriate catch() handling: * * try { * ... * } catch ( MWException $e ) { * $e->report(); * } catch ( Exception $e ) { * echo $e->__toString(); * } */ public static function handle($e) { global $wgFullyInitialised; self::report($e); // Final cleanup if ($wgFullyInitialised) { try { wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition } catch (Exception $e) { } } // Exit value should be nonzero for the benefit of shell jobs exit(1); }
/** * Ends this task peacefully */ function restInPeace(&$loadBalancer) { wfLogProfilingData(); $loadBalancer->closeAll(); wfDebug("Request ended normally\n"); }
/** * Ends this task peacefully */ function restInPeace() { wfLogProfilingData(); // Commit and close up! $factory = wfGetLBFactory(); $factory->commitMasterChanges(); $factory->shutdown(); wfDebug("Request ended normally\n"); }
/** * Ends this task peacefully * @param string $mode Use 'fast' to always skip job running */ public function restInPeace($mode = 'fast') { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); // Assure deferred updates are not in the main transaction $lbFactory->commitMasterChanges(__METHOD__); // Loosen DB query expectations since the HTTP client is unblocked $trxProfiler = Profiler::instance()->getTransactionProfiler(); $trxProfiler->resetExpectations(); $trxProfiler->setExpectations($this->config->get('TrxProfilerLimits')['PostSend'], __METHOD__); // Do any deferred jobs DeferredUpdates::doUpdates('enqueue'); DeferredUpdates::setImmediateMode(true); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); // Now that everything specific to this request is done, // try to occasionally run jobs (if enabled) from the queues if ($mode === 'normal') { $this->triggerJobs(); } // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); // Commit and close up! $lbFactory->commitMasterChanges(__METHOD__); $lbFactory->shutdown(LBFactory::SHUTDOWN_NO_CHRONPROT); wfDebug("Request ended normally\n"); }
/** * Ends this task peacefully * @param string $mode Use 'fast' to always skip job running */ public function restInPeace($mode = 'fast') { // Assure deferred updates are not in the main transaction wfGetLBFactory()->commitMasterChanges(__METHOD__); // Ignore things like master queries/connections on GET requests // as long as they are in deferred updates (which catch errors). Profiler::instance()->getTransactionProfiler()->resetExpectations(); // Do any deferred jobs DeferredUpdates::doUpdates('enqueue'); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); // Now that everything specific to this request is done, // try to occasionally run jobs (if enabled) from the queues if ($mode === 'normal') { $this->triggerJobs(); } // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); // Commit and close up! $factory = wfGetLBFactory(); $factory->commitMasterChanges(__METHOD__); $factory->shutdown(LBFactory::SHUTDOWN_NO_CHRONPROT); wfDebug("Request ended normally\n"); }
/** * Ends this task peacefully */ public function restInPeace() { // Ignore things like master queries/connections on GET requests // as long as they are in deferred updates (which catch errors). Profiler::instance()->getTransactionProfiler()->resetExpectations(); // Do any deferred jobs DeferredUpdates::doUpdates('commit'); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); // Commit and close up! $factory = wfGetLBFactory(); $factory->commitMasterChanges(); $factory->shutdown(); wfDebug("Request ended normally\n"); }
/** * Exception handler which simulates the appropriate catch() handling: * * try { * ... * } catch ( MWException $e ) { * $e->report(); * } catch ( Exception $e ) { * echo $e->__toString(); * } */ function wfExceptionHandler($e) { global $wgFullyInitialised; wfReportException($e); // Final cleanup, similar to wfErrorExit() if ($wgFullyInitialised) { try { wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition } catch (Exception $e) { } } // Exit value should be nonzero for the benefit of shell jobs exit(1); }
/** * Just like exit() but makes a note of it. * Commits open transactions except if the error parameter is set * * @deprecated Please return control to the caller or throw an exception */ function wfAbruptExit($error = false) { static $called = false; if ($called) { exit(-1); } $called = true; $bt = wfDebugBacktrace(); if ($bt) { for ($i = 0; $i < count($bt); $i++) { $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; wfDebug("WARNING: Abrupt exit in {$file} at line {$line}\n"); } } else { wfDebug("WARNING: Abrupt exit\n"); } wfLogProfilingData(); if (!$error) { wfGetLB()->closeAll(); } exit(-1); }
/** * Just like exit() but makes a note of it. * Commits open transactions except if the error parameter is set * * @obsolete Please return control to the caller or throw an exception */ function wfAbruptExit($error = false) { global $wgLoadBalancer; static $called = false; if ($called) { exit(-1); } $called = true; if (function_exists('debug_backtrace')) { // PHP >= 4.3 $bt = debug_backtrace(); for ($i = 0; $i < count($bt); $i++) { $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; wfDebug("WARNING: Abrupt exit in {$file} at line {$line}\n"); } } else { wfDebug('WARNING: Abrupt exit\\n'); } wfLogProfilingData(); if (!$error) { $wgLoadBalancer->closeAll(); } exit(-1); }
/** * Issue a standard HTTP 403 Forbidden header ($msg1-a message index, not a message) and an * error message ($msg2, also a message index), (both required) then end the script * subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2 */ function wfForbidden($msg1, $msg2) { global $wgImgAuthDetails; $args = func_get_args(); array_shift($args); array_shift($args); $MsgHdr = htmlspecialchars(wfMsg($msg1)); $detailMsg = htmlspecialchars(wfMsg($wgImgAuthDetails ? $msg2 : 'badaccess-group0', $args)); wfDebugLog('img_auth', "wfForbidden Hdr:" . wfMsgExt($msg1, array('language' => 'en')) . " Msg: " . wfMsgExt($msg2, array('language' => 'en'), $args)); header('HTTP/1.0 403 Forbidden'); header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); echo <<<ENDS <html> <body> <h1>{$MsgHdr}</h1> <p>{$detailMsg}</p> </body> </html> ENDS; wfLogProfilingData(); exit; }
/** * Ends this task peacefully */ public function restInPeace() { // Do any deferred jobs DeferredUpdates::doUpdates('commit'); // Execute a job from the queue $this->doJobs(); // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); // Commit and close up! $factory = wfGetLBFactory(); $factory->commitMasterChanges(); $factory->shutdown(); wfDebug("Request ended normally\n"); }
/** * Show a 403 error for use when the wiki is public */ function wfPublicError() { header('HTTP/1.0 403 Forbidden'); header('Content-Type: text/html; charset=utf-8'); echo <<<ENDS <html> <body> <h1>Access Denied</h1> <p>The function of img_auth.php is to output files from a private wiki. This wiki is configured as a public wiki. For optimal security, img_auth.php is disabled in this case. </p> </body> </html> ENDS; wfLogProfilingData(); exit; }
// OK, no valid thumbnail, time to get out the heavy machinery wfProfileOut('thumb.php-start'); require_once 'Setup.php'; wfProfileIn('thumb.php-render'); $img = Image::newFromName($fileName); try { if ($img) { if (!is_null($page)) { $img->selectPage($page); } $thumb = $img->renderThumb($width, false); } else { $thumb = false; } } catch (Exception $ex) { // Tried to select a page on a non-paged file? $thumb = false; } if ($thumb && $thumb->path) { wfStreamFile($thumb->path); } else { $badtitle = wfMsg('badtitle'); $badtitletext = wfMsg('badtitletext'); header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); echo "<html><head>\n\t<title>{$badtitle}</title>\n\t<body>\n<h1>{$badtitle}</h1>\n<p>{$badtitletext}</p>\n</body></html>\n"; } wfProfileOut('thumb.php-render'); wfProfileOut('thumb.php'); wfLogProfilingData();
/** * Ends this task peacefully */ function restInPeace() { wfLogProfilingData(); wfDebug("Request ended normally\n"); }