summaryrefslogtreecommitdiff
path: root/api.php
diff options
context:
space:
mode:
Diffstat (limited to 'api.php')
-rw-r--r--api.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/api.php b/api.php
index 5c675b06..39d27dd6 100644
--- a/api.php
+++ b/api.php
@@ -37,8 +37,18 @@
// So extensions (and other code) can check whether they're running in API mode
define( 'MW_API', true );
-// Initialise common code
-require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
+// Bail if PHP is too low
+if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.2.3' ) < 0 ) {
+ require( dirname( __FILE__ ) . '/includes/PHPVersionError.php' );
+ wfPHPVersionError( 'api.php' );
+}
+
+// Initialise common code.
+if ( isset( $_SERVER['MW_COMPILED'] ) ) {
+ require ( 'phase3/includes/WebStart.php' );
+} else {
+ require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
+}
wfProfileIn( 'api.php' );
$starttime = microtime( true );
@@ -50,9 +60,10 @@ if ( !$wgRequest->checkUrlExtension() ) {
// Verify that the API has not been disabled
if ( !$wgEnableAPI ) {
- echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
- echo '<pre><b>$wgEnableAPI=true;</b></pre>';
- die( 1 );
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
+ echo( 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php'
+ . '<pre><b>$wgEnableAPI=true;</b></pre>' );
+ die(1);
}
// Selectively allow cross-site AJAX
@@ -120,7 +131,8 @@ if ( $wgAPIRequestLog ) {
$_SERVER['HTTP_USER_AGENT']
);
$items[] = $wgRequest->wasPosted() ? 'POST' : 'GET';
- if ( $processor->getModule()->mustBePosted() ) {
+ $module = $processor->getModule();
+ if ( $module->mustBePosted() ) {
$items[] = "action=" . $wgRequest->getVal( 'action' );
} else {
$items[] = wfArrayToCGI( $wgRequest->getValues() );
@@ -129,6 +141,8 @@ if ( $wgAPIRequestLog ) {
wfDebug( "Logged API request to $wgAPIRequestLog\n" );
}
-// Shut down the database
-wfGetLBFactory()->shutdown();
+// Shut down the database. foo()->bar() syntax is not supported in PHP4: we won't ever actually
+// get here to worry about whether this should be = or =&, but the file has to parse properly.
+$lb = wfGetLBFactory();
+$lb->shutdown();