Go to the documentation of this file.
33 define(
'MW_API',
true );
34 define(
'MW_ENTRY_POINT',
'api' );
36 require __DIR__ .
'/includes/WebStart.php';
47 if ( isset( $_SERVER[
'PATH_INFO'] ) && $_SERVER[
'PATH_INFO'] !=
'' ) {
50 header(
"Location: $correctUrl",
true, 301 );
51 echo
'This endpoint does not support "path info", i.e. extra text between "api.php"'
52 .
'and the "?". Remove any such text and try again.';
71 Hooks::run(
'ApiBeforeMain', [ &$processor ] );
72 if ( !$processor instanceof
ApiMain ) {
73 throw new MWException(
'ApiBeforeMain hook set $processor to a non-ApiMain class' );
75 }
catch ( Exception $e ) {
79 }
catch ( Throwable $e ) {
87 $processor->execute();
101 $items[] =
$wgRequest->wasPosted() ?
'POST' :
'GET';
104 $manager = $processor->getModuleManager();
105 $module = $manager->getModule(
$wgRequest->getVal(
'action' ),
'action' );
106 }
catch ( Exception $ex ) {
108 }
catch ( Throwable $ex ) {
111 if ( !$module || $module->mustBePosted() ) {
112 $items[] =
"action=" .
$wgRequest->getVal(
'action' );
117 $items[] =
"failed in ApiBeforeMain";
120 wfDebug(
"Logged API request to $wgAPIRequestLog\n" );
This is the main API class, used for both external and internal processing.
if( $wgAPIRequestLog) $mediawiki
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
$wgAPIRequestLog
Log file or URL (TCP or UDP) to log API requests to, or false to disable API request logging.
if(! $processor instanceof ApiMain) catch(Exception $e) catch(Throwable $e) if( $processor) $endtime
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static getMain()
Get the RequestContext object associated with the main request.
static handleApiBeforeMainException( $e)
Handle an exception from the ApiBeforeMain hook.
if(! $wgDBerrorLogTZ) $wgRequest
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....