-
Notifications
You must be signed in to change notification settings - Fork 1
/
wikia.php
56 lines (43 loc) · 1.69 KB
/
wikia.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// This is from google translate, just return early.
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header ( "HTTP/1.1 200", true, 200);
return;
}
// Initialise common MW code
require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
if ($wgProfiler instanceof Profiler) {
$wgProfiler->setTemplated(true);
}
// Construct a tag for newrelic -- wgRequest is global in this scope
if( function_exists( 'newrelic_name_transaction' ) ) {
if ( function_exists( 'newrelic_disable_autorum') ) {
newrelic_disable_autorum();
}
newrelic_name_transaction('Nirvana');
if ( function_exists( 'newrelic_add_custom_parameter' ) && is_object($wgRequest)) {
newrelic_add_custom_parameter( 'controller', $wgRequest->getVal( 'controller' ) );
newrelic_add_custom_parameter( 'method', $wgRequest->getVal( '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 );
}
$response->sendHeaders();
$response->render();
wfLogProfilingData();
} else {
header( "HTTP/1.1 503 Service Unavailable", true, 503 );
}