Esempio n. 1
0
if( function_exists( 'newrelic_name_transaction' ) ) {
	if ( function_exists( 'newrelic_disable_autorum') ) {
		newrelic_disable_autorum();
	}
	if (is_object($wgRequest)) {
		$controller = $wgRequest->getVal( 'controller' );
		$method = $wgRequest->getVal( 'method' );
		newrelic_name_transaction( "/nirvana/$controller/$method" );
	}
}

if ( !empty( $wgEnableNirvanaAPI ) ){
	$app = F::app();
	
	// Ensure that we have a title stub, otherwise parser does not work BugId: 12901
	$app->wg->title = Wikia::createTitleFromRequest( $app->wg->Request );
	
	// initialize skin if requested
	$app->initSkin( (bool) $app->wg->Request->getVal( "skin", false ) );
	
	$response = $app->sendRequest( null, null, null, false );
	
	// commit any open transactions just in case the controller forgot to
	$app->commit();

	//if cache policy wasn't explicitly set (e.g. WikiaResponse::setCacheValidity)
	//then force no cache to reflect api.php default behavior
	$cacheControl = $response->getHeader( 'Cache-Control' );

	if ( empty( $cacheControl ) ) {
		$response->setHeader( 'Cache-Control', 'private', true );
Esempio n. 2
0
 private function main()
 {
     global $wgUseFileCache, $wgTitle, $wgUseAjax;
     wfProfileIn(__METHOD__);
     $request = $this->context->getRequest();
     // Send Ajax requests to the Ajax dispatcher.
     if ($wgUseAjax && $request->getVal('action', 'view') == 'ajax') {
         // Set a dummy title, because $wgTitle == null might break things
         // Wikia change - start
         // @author macbre, wladek
         $title = Wikia::createTitleFromRequest($request);
         // Wikia change - end
         $this->context->setTitle($title);
         $wgTitle = $title;
         $dispatcher = new AjaxDispatcher();
         $dispatcher->performAction();
         wfProfileOut(__METHOD__);
         return;
     }
     // Get title from request parameters,
     // is set on the fly by parseTitle the first time.
     $title = $this->getTitle();
     $action = $this->getAction();
     $wgTitle = $title;
     if ($wgUseFileCache && $title->getNamespace() >= 0) {
         wfProfileIn('main-try-filecache');
         if (HTMLFileCache::useFileCache($this->context)) {
             // Try low-level file cache hit
             $cache = HTMLFileCache::newFromTitle($title, $action);
             if ($cache->isCacheGood()) {
                 // Check incoming headers to see if client has this cached
                 $timestamp = $cache->cacheTimestamp();
                 if (!$this->context->getOutput()->checkLastModified($timestamp)) {
                     $cache->loadFromFileCache($this->context);
                 }
                 // Do any stats increment/watchlist stuff
                 $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');
     }
     $this->performRequest();
     $this->finalCleanup();
     wfProfileOut(__METHOD__);
 }