X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=api.php;h=83c1373c14a97b645ad1d7948e1b774ded6806d0;hb=4b328d6c2e12d9c37406e3652a52f691a7ae02e6;hp=7788a36c2f952e33860018752218fdbc6e119481;hpb=5f690a2c46fb289fd9b1e8865a4d189067da719c;p=lhc%2Fweb%2Fwiklou.git diff --git a/api.php b/api.php index 7788a36c2f..83c1373c14 100644 --- a/api.php +++ b/api.php @@ -30,16 +30,11 @@ * @file */ +use MediaWiki\Logger\LegacyLogger; + // So extensions (and other code) can check whether they're running in API mode define( 'MW_API', true ); -// Bail if PHP is too low -if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.3' ) < 0 ) { - // We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+ - require dirname( __FILE__ ) . '/includes/PHPVersionError.php'; - wfPHPVersionError( 'api.php' ); -} - require __DIR__ . '/includes/WebStart.php'; $starttime = microtime( true ); @@ -59,7 +54,7 @@ if ( !$wgEnableAPI ) { // Set a dummy $wgTitle, because $wgTitle == null breaks various things // In a perfect world this wouldn't be necessary -$wgTitle = Title::makeTitle( NS_MAIN, 'API' ); +$wgTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/dummy title for API calls set in api.php' ); // RequestContext will read from $wgTitle, but it will also whine about it. // In a perfect world this wouldn't be necessary either. @@ -73,7 +68,7 @@ try { $processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI ); // Last chance hook before executing the API - wfRunHooks( 'ApiBeforeMain', array( &$processor ) ); + Hooks::run( 'ApiBeforeMain', array( &$processor ) ); if ( !$processor instanceof ApiMain ) { throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' ); } @@ -88,18 +83,9 @@ if ( $processor ) { $processor->execute(); } -if ( function_exists( 'fastcgi_finish_request' ) ) { - fastcgi_finish_request(); -} - -// Execute any deferred updates -DeferredUpdates::doUpdates(); - // Log what the user did, for book-keeping purposes. $endtime = microtime( true ); -wfLogProfilingData(); - // Log the request if ( $wgAPIRequestLog ) { $items = array( @@ -124,11 +110,9 @@ if ( $wgAPIRequestLog ) { } else { $items[] = "failed in ApiBeforeMain"; } - MWLoggerLegacyLogger::emit( implode( ',', $items ) . "\n", $wgAPIRequestLog ); + LegacyLogger::emit( implode( ',', $items ) . "\n", $wgAPIRequestLog ); wfDebug( "Logged API request to $wgAPIRequestLog\n" ); } -// 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(); +$mediawiki = new MediaWiki(); +$mediawiki->doPostOutputShutdown( 'fast' );