94 $starttime = microtime(
true );
96 $services = $this->getServiceContainer();
100 $pathInfo = $this->environment->getServerInfo(
'PATH_INFO',
'' );
101 if ( $pathInfo !=
'' ) {
104 $request->getQueryValuesOnly()
106 $correctUrl = (string)$services->getUrlUtils()->expand(
111 "Location: $correctUrl",
116 'This endpoint does not support "path info", i.e. extra text ' .
117 'between "api.php" and the "?". Remove any such text and try again.'
126 'Badtitle/dummy title for API calls set in api.php'
144 (
new HookRunner( $services->getHookContainer() ) )->onApiBeforeMain( $processor );
145 if ( !$processor instanceof
ApiMain ) {
146 throw new LogicException(
147 'ApiBeforeMain hook set $processor to a non-ApiMain class'
150 }
catch ( Throwable $e ) {
158 $processor->execute();
162 $endtime = microtime(
true );
165 if ( $apiRequestLog ) {
168 $endtime - $starttime,
170 $request->getHeader(
'User-agent' )
172 $items[] = $request->wasPosted() ?
'POST' :
'GET';
175 $manager = $processor->getModuleManager();
176 $module = $manager->getModule(
177 $request->getRawVal(
'action' ),
180 }
catch ( Throwable $ex ) {
183 if ( !$module || $module->mustBePosted() ) {
184 $items[] =
"action=" . $request->getRawVal(
'action' );
189 $items[] =
"failed in ApiBeforeMain";
198 wfDebug(
"Logged API request to $apiRequestLog" );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfScript( $script='index')
Get the URL path to a MediaWiki entry point.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgTitle
This is the main API class, used for both external and internal processing.
static handleApiBeforeMainException(Throwable $e)
Handle a throwable from the ApiBeforeMain hook.
Implementation of the API entry point, for web browser navigations, usually via an Action or SpecialP...
execute()
Executes a request to the action API.
getContext()
Overwritten to narrow the return type to RequestContext.
__construct(RequestContext $context, EntryPointEnvironment $environment, MediaWikiServices $services)
Group all the pieces relevant to the context of a request into one instance.
Utility class wrapping PHP runtime state.
A class containing constants representing the names of configuration variables.
const APIRequestLog
Name constant for the APIRequestLog setting, for use with Config::get()
Base class for entry point handlers.
EntryPointEnvironment $environment