$request = $this->context->getRequest();
$curid = $request->getInt( 'curid' );
$title = $request->getVal( 'title' );
- $action = $request->getVal( 'action', 'view' );
+ $action = $request->getVal( 'action' );
if ( $request->getCheck( 'search' ) ) {
// Compatibility with old search URLs which didn't use Special:Search
private function performRequest() {
global $wgTitle;
- wfProfileIn( __METHOD__ );
-
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
}
$unused = null; // To pass it by reference
- wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) );
+ Hooks::run( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) );
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if ( is_null( $title ) || ( $title->getDBkey() == '' && !$title->isExternal() )
|| $title->isSpecial( 'Badtitle' )
) {
$this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
- wfProfileOut( __METHOD__ );
throw new BadTitleError();
}
$this->context->setTitle( $badTitle );
$wgTitle = $badTitle;
- wfProfileOut( __METHOD__ );
throw new PermissionsError( 'read', $permErrors );
}
$output->redirect( $url, 301 );
} else {
$this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
- wfProfileOut( __METHOD__ );
throw new BadTitleError();
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
&& ( $request->getVal( 'title' ) === null
|| $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
&& !count( $request->getValueNames( array( 'action', 'title' ) ) )
- && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) )
+ && Hooks::run( 'TestCanonicalRedirect', array( $request, $title, $output ) )
) {
if ( $title->isSpecialPage() ) {
list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
} else {
- wfProfileOut( __METHOD__ );
throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle()"
. " returned neither an object nor a URL" );
}
$user->addAutopromoteOnceGroups( 'onView' );
}
- wfProfileOut( __METHOD__ );
}
/**
* @return mixed An Article, or a string to redirect to another URL
*/
private function initializeArticle() {
- wfProfileIn( __METHOD__ );
$title = $this->context->getTitle();
if ( $this->context->canUseWikiPage() ) {
// NS_MEDIAWIKI has no redirects.
// It is also used for CSS/JS, so performance matters here...
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
- wfProfileOut( __METHOD__ );
return $article;
}
// Give extensions a change to ignore/handle redirects as needed
$ignoreRedirect = $target = false;
- wfRunHooks( 'InitializeArticleMaybeRedirect',
+ Hooks::run( 'InitializeArticleMaybeRedirect',
array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) );
// Follow redirects only for... redirects.
if ( is_string( $target ) ) {
if ( !$this->config->get( 'DisableHardRedirects' ) ) {
// we'll need to redirect
- wfProfileOut( __METHOD__ );
return $target;
}
}
}
}
- wfProfileOut( __METHOD__ );
return $article;
}
* @param Title $requestTitle The original title, before any redirects were applied
*/
private function performAction( Page $page, Title $requestTitle ) {
- wfProfileIn( __METHOD__ );
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
- if ( !wfRunHooks( 'MediaWikiPerformAction',
+ if ( !Hooks::run( 'MediaWikiPerformAction',
array( $output, $page, $title, $user, $request, $this ) )
) {
- wfProfileOut( __METHOD__ );
return;
}
}
$action->show();
- wfProfileOut( __METHOD__ );
return;
}
- if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) {
+ if ( Hooks::run( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) {
$output->setStatusCode( 404 );
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
}
- wfProfileOut( __METHOD__ );
}
/**
* @return bool
*/
private function checkMaxLag() {
- wfProfileIn( __METHOD__ );
$maxLag = $this->context->getRequest()->getVal( 'maxlag' );
if ( !is_null( $maxLag ) ) {
list( $host, $lag ) = wfGetLB()->getMaxLag();
echo "Waiting for a database server: $lag seconds lagged\n";
}
- wfProfileOut( __METHOD__ );
-
exit;
}
}
- wfProfileOut( __METHOD__ );
return true;
}
private function main() {
global $wgTitle;
- wfProfileIn( __METHOD__ );
-
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
- if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action', 'view' ) == 'ajax' ) {
-
+ if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action' ) === 'ajax' ) {
// Set a dummy title, because $wgTitle == null might break things
$title = Title::makeTitle( NS_MAIN, 'AJAX' );
$this->context->setTitle( $title );
$dispatcher = new AjaxDispatcher( $this->config );
$dispatcher->performAction( $this->context->getUser() );
- wfProfileOut( __METHOD__ );
return;
}
$redirUrl = preg_replace( '#^http://#', 'https://', $oldUrl );
// ATTENTION: This hook is likely to be removed soon due to overall design of the system.
- if ( wfRunHooks( 'BeforeHttpsRedirect', array( $this->context, &$redirUrl ) ) ) {
+ if ( Hooks::run( 'BeforeHttpsRedirect', array( $this->context, &$redirUrl ) ) ) {
if ( $request->wasPosted() ) {
// This is weird and we'd hope it almost never happens. This
$output->addVaryHeader( 'X-Forwarded-Proto' );
$output->redirect( $redirUrl );
$output->output();
- wfProfileOut( __METHOD__ );
return;
}
}
if ( $this->config->get( 'UseFileCache' ) && $title->getNamespace() >= 0 ) {
- wfProfileIn( 'main-try-filecache' );
if ( HTMLFileCache::useFileCache( $this->context ) ) {
// Try low-level file cache hit
$cache = new HTMLFileCache( $title, $action );
$this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
- wfProfileOut( 'main-try-filecache' );
- wfProfileOut( __METHOD__ );
return;
}
}
- wfProfileOut( 'main-try-filecache' );
}
// Actually do the work of the request and build up any output
// Output everything!
$this->context->getOutput()->output();
- wfProfileOut( __METHOD__ );
}
/**
return; // recursion guard
}
- $section = new ProfileSection( __METHOD__ );
-
if ( $jobRunRate < 1 ) {
$max = mt_getrandmax();
if ( mt_rand( 0, $max ) > $max * $jobRunRate ) {
$n = intval( $jobRunRate );
}
+ $runJobsLogger = MWLoggerFactory::getInstance( 'runJobs' );
+
if ( !$this->config->get( 'RunJobsAsync' ) ) {
// Fall back to running the job here while the user waits
- $runner = new JobRunner();
+ $runner = new JobRunner( $runJobsLogger );
$runner->run( array( 'maxJobs' => $n ) );
return;
}
);
wfRestoreWarnings();
if ( !$sock ) {
- wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" );
+ $runJobsLogger->error( "Failed to start cron API (socket error $errno): $errstr" );
// Fall back to running the job here while the user waits
- $runner = new JobRunner();
+ $runner = new JobRunner( $runJobsLogger );
$runner->run( array( 'maxJobs' => $n ) );
return;
}
$url = wfAppendQuery( wfScript( 'index' ), $query );
$req = "POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\nContent-Length: 0\r\n\r\n";
- wfDebugLog( 'runJobs', "Running $n job(s) via '$url'\n" );
+ $runJobsLogger->info( "Running $n job(s) via '$url'" );
// Send a cron API request to be performed in the background.
// Give up if this takes too long to send (which should be rare).
stream_set_timeout( $sock, 1 );
$bytes = fwrite( $sock, $req );
if ( $bytes !== strlen( $req ) ) {
- wfDebugLog( 'runJobs', "Failed to start cron API (socket write error)\n" );
+ $runJobsLogger->error( "Failed to start cron API (socket write error)" );
} else {
// Do not wait for the response (the script should handle client aborts).
// Make sure that we don't close before that script reaches ignore_user_abort().
$status = fgets( $sock );
if ( !preg_match( '#^HTTP/\d\.\d 202 #', $status ) ) {
- wfDebugLog( 'runJobs', "Failed to start cron API: received '$status'\n" );
+ $runJobsLogger->error( "Failed to start cron API: received '$status'" );
}
}
fclose( $sock );