X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=api.php;h=9cf75787ba1a387cfa4dd0699d0aa4e48c12d3f4;hp=d9a69db37e62a25d596982d74d788753273cc1b1;hb=05b2874f376d568d293aa46f21a3f7b484a984be;hpb=fbb86f07d222ba6c31386472c5b792348b1c89e2 diff --git a/api.php b/api.php index d9a69db37e..9cf75787ba 100644 --- a/api.php +++ b/api.php @@ -2,13 +2,10 @@ /** * This file is the entry point for all API queries. * - * It begins by checking whether the API is enabled on this wiki; if not, - * it informs the user that s/he should set $wgEnableAPI to true and exits. - * Otherwise, it constructs a new ApiMain using the parameter passed to it - * as an argument in the URL ('?action=') and with write-enabled set to the - * value of $wgEnableWriteAPI as specified in LocalSettings.php. - * It then invokes "execute()" on the ApiMain object instance, which - * produces output in the format specified in the URL. + * It begins by constructing a new ApiMain using the parameter passed to it + * as an argument in the URL ('?action='). It then invokes "execute()" on the + * ApiMain object instance, which produces output in the format specified in + * the URL. * * Copyright © 2006 Yuri Astrakhan @gmail.com * @@ -55,14 +52,6 @@ if ( isset( $_SERVER['PATH_INFO'] ) && $_SERVER['PATH_INFO'] != '' ) { die( 1 ); } -// Verify that the API has not been disabled -if ( !$wgEnableAPI ) { - 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' - . '
$wgEnableAPI=true;
'; - die( 1 ); -} - // Set a dummy $wgTitle, because $wgTitle == null breaks various things // In a perfect world this wouldn't be necessary $wgTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/dummy title for API calls set in api.php' ); @@ -76,14 +65,18 @@ try { * is some form of an ApiMain, possibly even one that produces an error message, * but we don't care here, as that is handled by the constructor. */ - $processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI ); + $processor = new ApiMain( RequestContext::getMain(), true ); // Last chance hook before executing the API Hooks::run( 'ApiBeforeMain', [ &$processor ] ); if ( !$processor instanceof ApiMain ) { throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' ); } -} catch ( Exception $e ) { +} catch ( Exception $e ) { // @todo Remove this block when HHVM is no longer supported + // Crap. Try to report the exception in API format to be friendly to clients. + ApiMain::handleApiBeforeMainException( $e ); + $processor = false; +} catch ( Throwable $e ) { // Crap. Try to report the exception in API format to be friendly to clients. ApiMain::handleApiBeforeMainException( $e ); $processor = false; @@ -110,7 +103,9 @@ if ( $wgAPIRequestLog ) { try { $manager = $processor->getModuleManager(); $module = $manager->getModule( $wgRequest->getVal( 'action' ), 'action' ); - } catch ( Exception $ex ) { + } catch ( Exception $ex ) { // @todo Remove this block when HHVM is no longer supported + $module = null; + } catch ( Throwable $ex ) { $module = null; } if ( !$module || $module->mustBePosted() ) {