MediaWiki master
|
Base class for entry point handlers. More...
Inherited by MediaWiki, MediaWiki\Actions\ActionEntryPoint, MediaWiki\Api\ApiEntryPoint, MediaWiki\FileRepo\AuthenticatedFileEntryPoint, MediaWiki\FileRepo\ThumbnailEntryPoint, MediaWiki\ResourceLoader\ResourceLoaderEntryPoint, and MediaWiki\Rest\EntryPoint.
Public Member Functions | |
__construct (IContextSource $context, EntryPointEnvironment $environment, MediaWikiServices $mediaWikiServices) | |
enableOutputCapture () | |
Enable capturing of the current output buffer. | |
getCapturedOutput () | |
Stop capturing and return all output. | |
getRequestPathSuffix ( $basePath) | |
If the request URL matches a given base path, extract the path part of the request URL after that base, and decode escape sequences in it. | |
run () | |
Main app life cycle: Calls doSetup(), execute(), prepareForOutput(), and postOutputShutdown(). | |
Static Public Member Functions | |
static | emitBufferedStatsdData (IBufferingStatsdDataFactory $stats, Config $config) |
Send out any buffered statsd data according to sampling rules. | |
Protected Member Functions | |
commitMainTransaction () | |
This function commits all DB and session changes as needed before the client can receive a response (in case DB commit fails) and thus also before the response can trigger a subsequent related request by the client. | |
commitOutputBuffer () | |
Ends the current output buffer, appending its content to the parent buffer. | |
disableModDeflate () | |
discardAllOutput () | |
Discards all buffered output, down to the capture buffer level. | |
discardOutputBuffer () | |
doPostOutputShutdown () | |
Forces the response to be sent to the client and then does work that can be done after the user gets the HTTP response, so they don't block on it. | |
doPrepareForOutput () | |
Prepare for sending the output. | |
doSetup () | |
Perform any setup needed before execute() is called. | |
drainOutputBuffer () | |
Returns the content of the current output buffer and clears it. | |
enterPostSendMode () | |
Disables all output to the client. | |
execute () | |
Subclasses implement the entry point's functionality by overriding this method. | |
exit (int $code=0) | |
fastCgiFinishRequest () | |
Calls fastcgi_finish_request if possible. | |
flushOutputBuffer () | |
Flush buffered output to the client. | |
getBlockManager () | |
getConfig (string $key) | |
getContext () | |
getDBLoadBalancerFactory () | |
getEnv (string $name) | |
Returns the value of an environment variable. | |
getIni (string $name) | |
Returns the value of an ini option. | |
getJobQueueGroupFactory () | |
getJobRunner () | |
getMessageCache () | |
getOutputBufferLength () | |
getOutputBufferLevel () | |
Returns the output buffer level. | |
getOutputBufferStatus () | |
getReadOnlyMode () | |
getRequest () | |
getRequestURL () | |
Returns the current request's path and query string (not a full URL), like PHP's built-in $_SERVER['REQUEST_URI']. | |
getResponse () | |
getServerInfo (string $key, $default=null) | |
getServiceContainer () | |
Returns the main service container. | |
getSpecialPageFactory () | |
getStatsdDataFactory () | |
getStatsFactory () | |
getStatusCode () | |
getUrlUtils () | |
handleTopLevelError (Throwable $e) | |
Report a top level error. | |
hasFastCgi () | |
header (string $header, bool $replace=true, int $status=0) | |
inPostSendMode () | |
Whether enterPostSendMode() has been called. | |
isCli () | |
outputResponsePayload ( $content) | |
Print a response body to the current buffer (if there is one) or the server (otherwise) | |
postOutputShutdown () | |
Forces the response to be sent to the client and then does work that can be done after the user gets the HTTP response, so they don't block on it. | |
prepareForOutput () | |
Prepare for sending the output. | |
print ( $data) | |
restInPeace () | |
Ends this task peacefully. | |
schedulePostSendJobs () | |
If enabled, after everything specific to this request is done, occasionally run jobs. | |
setIniOption (string $name, $value) | |
setup () | |
Perform any setup needed before execute() is called. | |
shouldDoHttpRedirect () | |
Check if an HTTP->HTTPS redirect should be done. | |
startOutputBuffer (?callable $callback=null) | |
Adds a new output buffer level. | |
status (int $code) | |
triggerAsyncJobs ( $n, LoggerInterface $runJobsLogger) | |
triggerError (string $message, int $level=E_USER_NOTICE) | |
Triggers a PHP runtime error. | |
triggerSyncJobs ( $n) | |
Protected Attributes | |
EntryPointEnvironment | $environment |
Base class for entry point handlers.
Definition at line 77 of file MediaWikiEntryPoint.php.
MediaWiki\MediaWikiEntryPoint::__construct | ( | IContextSource | $context, |
EntryPointEnvironment | $environment, | ||
MediaWikiServices | $mediaWikiServices ) |
IContextSource | $context | |
EntryPointEnvironment | $environment | |
MediaWikiServices | $mediaWikiServices |
Definition at line 109 of file MediaWikiEntryPoint.php.
References MediaWiki\Context\IContextSource\getConfig(), MediaWiki\EntryPointEnvironment\hasFastCgi(), and MediaWiki\EntryPointEnvironment\isCli().
|
protected |
This function commits all DB and session changes as needed before the client can receive a response (in case DB commit fails) and thus also before the response can trigger a subsequent related request by the client.
Definition at line 282 of file MediaWikiEntryPoint.php.
References $url, MediaWiki\Config\Config\get(), MediaWiki\Context\IContextSource\getConfig(), MediaWiki\Context\IContextSource\getOutput(), MediaWiki\Context\IContextSource\getRequest(), MediaWiki\Context\IContextSource\getUser(), wfDebug(), and wfDebugLog().
|
protected |
Ends the current output buffer, appending its content to the parent buffer.
Definition at line 995 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1130 of file MediaWikiEntryPoint.php.
|
protected |
Discards all buffered output, down to the capture buffer level.
Definition at line 1098 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1126 of file MediaWikiEntryPoint.php.
|
protected |
Forces the response to be sent to the client and then does work that can be done after the user gets the HTTP response, so they don't block on it.
Reimplemented in MediaWiki.
Definition at line 473 of file MediaWikiEntryPoint.php.
|
protected |
Prepare for sending the output.
Should be called by entry points before sending the response. Will be called automatically by run() via prepareForOutput(). Subclasses may override this method, but should not call it directly.
Reimplemented in MediaWiki\Actions\ActionEntryPoint, MediaWiki\FileRepo\ThumbnailEntryPoint, and MediaWiki\ResourceLoader\ResourceLoaderEntryPoint.
Definition at line 184 of file MediaWikiEntryPoint.php.
|
protected |
Perform any setup needed before execute() is called.
Called by doRun() via doSetup().
Reimplemented in MediaWiki\Rest\EntryPoint.
Definition at line 147 of file MediaWikiEntryPoint.php.
|
protected |
Returns the content of the current output buffer and clears it.
Definition at line 939 of file MediaWikiEntryPoint.php.
|
static |
Send out any buffered statsd data according to sampling rules.
For web requests, this is called once by MediaWiki::restInPeace(), which is post-send (after the response is sent to the client).
For maintenance scripts, especially long-running CLI scripts, it is called more often, to avoid OOM, since we buffer stats (T181385), based on the following heuristics:
IBufferingStatsdDataFactory | $stats | |
Config | $config |
ConfigException |
Definition at line 722 of file MediaWikiEntryPoint.php.
References IBufferingStatsdDataFactory\clearData(), MediaWiki\Config\Config\get(), IBufferingStatsdDataFactory\getData(), IBufferingStatsdDataFactory\getDataCount(), and IBufferingStatsdDataFactory\hasData().
MediaWiki\MediaWikiEntryPoint::enableOutputCapture | ( | ) |
Enable capturing of the current output buffer.
There may be mutiple levels of output buffering. The level we are currently at, at the time of calling this method, is the level that will be captured to later retrieve via getCapturedOutput().
When capturing is active, flushOutputBuffer() will not actually write to the real STDOUT, but instead write only to the capture.
This exists to ease testing.
Definition at line 965 of file MediaWikiEntryPoint.php.
|
protected |
Disables all output to the client.
After this, calling any output methods on this object will fail.
Definition at line 1255 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
abstractprotected |
Subclasses implement the entry point's functionality by overriding this method.
This method is not safe to override for extensions.
Reimplemented in MediaWiki\Actions\ActionEntryPoint, MediaWiki\Api\ApiEntryPoint, MediaWiki\FileRepo\AuthenticatedFileEntryPoint, MediaWiki\FileRepo\ThumbnailEntryPoint, MediaWiki, MediaWiki\ResourceLoader\ResourceLoaderEntryPoint, and MediaWiki\Rest\EntryPoint.
|
protected |
|
protected |
Calls fastcgi_finish_request if possible.
Reasons for not calling fastcgi_finish_request include the fastcgi extension not being loaded and the capture buffer level being different from 0.
Definition at line 1219 of file MediaWikiEntryPoint.php.
|
protected |
Flush buffered output to the client.
If enableOutputCapture() was called, buffered output is committed to the capture buffer instead.
If enterPostSendMode() was called before this method, a warning is triggered and any buffered output is discarded.
Definition at line 1045 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 857 of file MediaWikiEntryPoint.php.
MediaWiki\MediaWikiEntryPoint::getCapturedOutput | ( | ) |
Stop capturing and return all output.
It flushes and drains all output buffers, but lets it go to a return value instead of the real STDOUT.
You must call enableOutputCapture() and run() before getCapturedOutput().
Definition at line 1022 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 889 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute(), and MediaWiki\FileRepo\Thumbnail404EntryPoint\handleRequest().
|
protected |
Reimplemented in MediaWiki\Actions\ActionEntryPoint, and MediaWiki\Api\ApiEntryPoint.
Definition at line 877 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 849 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an environment variable.
string | $name |
Definition at line 1170 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an ini option.
string | $name |
Definition at line 1183 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 869 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 845 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 853 of file MediaWikiEntryPoint.php.
|
protected |
|
protected |
Returns the output buffer level.
If enableOutputCapture() has been called, the capture buffer level is taking into account by subtracting it from the actual buffer level.
Definition at line 986 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1119 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 841 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 881 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute(), MediaWiki\ResourceLoader\ResourceLoaderEntryPoint\execute(), and MediaWiki\FileRepo\ThumbnailEntryPoint\handleRequest().
MediaWiki\MediaWikiEntryPoint::getRequestPathSuffix | ( | $basePath | ) |
If the request URL matches a given base path, extract the path part of the request URL after that base, and decode escape sequences in it.
If the request URL does not match, false is returned.
string | $basePath |
Definition at line 441 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute(), and MediaWiki\FileRepo\Thumbnail404EntryPoint\handleRequest().
|
protected |
Returns the current request's path and query string (not a full URL), like PHP's built-in $_SERVER['REQUEST_URI'].
Definition at line 1246 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 885 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 901 of file MediaWikiEntryPoint.php.
|
protected |
Returns the main service container.
This is intended as a stepping stone for migration. Ideally, individual service objects should be injected via the constructor.
Definition at line 833 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute(), MediaWiki\ResourceLoader\ResourceLoaderEntryPoint\execute(), MediaWiki\FileRepo\Thumbnail404EntryPoint\extractThumbRequestInfo(), and MediaWiki\FileRepo\Thumbnail404EntryPoint\handleRequest().
|
protected |
Definition at line 873 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 865 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 861 of file MediaWikiEntryPoint.php.
|
protected |
|
protected |
Definition at line 837 of file MediaWikiEntryPoint.php.
|
protected |
Report a top level error.
Subclasses in core may override this to handle errors according to the expected output format. This method is not safe to override for extensions.
Throwable | $e |
Reimplemented in MediaWiki\Actions\ActionEntryPoint.
Definition at line 220 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 897 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1200 of file MediaWikiEntryPoint.php.
|
protected |
Whether enterPostSendMode() has been called.
Indicates whether more data can be sent to the client. To determine whether more headers can be sent, use $this->getResponse()->headersSent().
Definition at line 1148 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 893 of file MediaWikiEntryPoint.php.
|
protected |
Print a response body to the current buffer (if there is one) or the server (otherwise)
This method should be called after commitMainTransaction() and before doPostOutputShutdown()
Any accompanying Content-Type header is assumed to have already been set
string | $content | Response content, usually from OutputPage::output() |
Definition at line 567 of file MediaWikiEntryPoint.php.
References Profiler\instance().
|
finalprotected |
Forces the response to be sent to the client and then does work that can be done after the user gets the HTTP response, so they don't block on it.
Definition at line 453 of file MediaWikiEntryPoint.php.
|
finalprotected |
Prepare for sending the output.
Should be called by entry points before sending the response. Final wrapper function for doPrepareForOutput(). Will be called automatically at the end of doRun(), but will do nothing if it was already called from execute().
Definition at line 164 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 905 of file MediaWikiEntryPoint.php.
|
protected |
Ends this task peacefully.
Called after the response has been sent to the client. Subclasses in core may override this to add end-of-request code, but should always call the parent method. This method is not safe to override by extensions.
Reimplemented in MediaWiki.
Definition at line 654 of file MediaWikiEntryPoint.php.
References Profiler\instance(), and wfDebug().
|
final |
Main app life cycle: Calls doSetup(), execute(), prepareForOutput(), and postOutputShutdown().
Definition at line 196 of file MediaWikiEntryPoint.php.
|
protected |
If enabled, after everything specific to this request is done, occasionally run jobs.
Reimplemented in MediaWiki\Actions\ActionEntryPoint.
Definition at line 234 of file MediaWikiEntryPoint.php.
|
protected |
string | $name | |
mixed | $value |
Definition at line 1193 of file MediaWikiEntryPoint.php.
|
finalprotected |
Perform any setup needed before execute() is called.
Final wrapper function for setup(). Will be called by doRun().
Definition at line 133 of file MediaWikiEntryPoint.php.
|
protected |
Check if an HTTP->HTTPS redirect should be done.
It may still be aborted by a hook, so this is not the final word.
Definition at line 519 of file MediaWikiEntryPoint.php.
References PROTO_HTTPS.
|
protected |
Adds a new output buffer level.
?callable | $callback |
Definition at line 929 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1207 of file MediaWikiEntryPoint.php.
|
protected |
int | $n | Number of jobs to try to run |
LoggerInterface | $runJobsLogger |
Definition at line 756 of file MediaWikiEntryPoint.php.
References $url.
|
protected |
Triggers a PHP runtime error.
Definition at line 1157 of file MediaWikiEntryPoint.php.
|
protected |
int | $n | Number of jobs to try to run |
Definition at line 745 of file MediaWikiEntryPoint.php.
References Profiler\instance().
|
protected |
Definition at line 100 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\__construct(), and MediaWiki\Api\ApiEntryPoint\__construct().