36 define(
'MW_API',
true );
38 require __DIR__ .
'/includes/WebStart.php';
40 $starttime = microtime(
true );
48 if ( !$wgEnableAPI ) {
49 header( $_SERVER[
'SERVER_PROTOCOL'] .
' 500 MediaWiki configuration Error',
true, 500 );
50 echo
'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php'
51 .
'<pre><b>$wgEnableAPI=true;</b></pre>';
71 Hooks::run(
'ApiBeforeMain', [ &$processor ] );
72 if ( !$processor instanceof
ApiMain ) {
73 throw new MWException(
'ApiBeforeMain hook set $processor to a non-ApiMain class' );
83 $processor->execute();
90 if ( $wgAPIRequestLog ) {
97 $items[] =
$wgRequest->wasPosted() ?
'POST' :
'GET';
100 $manager = $processor->getModuleManager();
101 $module = $manager->getModule(
$wgRequest->getVal(
'action' ),
'action' );
105 if ( !$module || $module->mustBePosted() ) {
106 $items[] =
"action=" .
$wgRequest->getVal(
'action' );
111 $items[] =
"failed in ApiBeforeMain";
113 LegacyLogger::emit( implode(
',', $items ) .
"\n", $wgAPIRequestLog );
114 wfDebug(
"Logged API request to $wgAPIRequestLog\n" );
MediaWiki Logger LegacyLogger
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(!$wgDBerrorLogTZ) $wgRequest
static handleApiBeforeMainException(Exception $e)
Handle an exception from the ApiBeforeMain hook.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if($wgAPIRequestLog) $mediawiki
static getMain()
Static methods.
This is the main API class, used for both external and internal processing.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
wfArrayToCgi($array1, $array2=null, $prefix= '')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
if(!$wgRequest->checkUrlExtension()) if(!$wgEnableAPI) $wgTitle
if(!$processor instanceof ApiMain) catch(Exception $e) if($processor) $endtime
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
This document describes the state of Postgres support in MediaWiki