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 | emitBufferedStats (StatsFactory $statsFactory, IBufferingStatsdDataFactory $stats, Config $config) |
Send out any buffered stats 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 78 of file MediaWikiEntryPoint.php.
MediaWiki\MediaWikiEntryPoint::__construct | ( | IContextSource | $context, |
EntryPointEnvironment | $environment, | ||
MediaWikiServices | $mediaWikiServices ) |
IContextSource | $context | |
EntryPointEnvironment | $environment | |
MediaWikiServices | $mediaWikiServices |
Definition at line 110 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 283 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 1004 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1139 of file MediaWikiEntryPoint.php.
|
protected |
Discards all buffered output, down to the capture buffer level.
Definition at line 1107 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1135 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 474 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 185 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 148 of file MediaWikiEntryPoint.php.
|
protected |
Returns the content of the current output buffer and clears it.
Definition at line 948 of file MediaWikiEntryPoint.php.
|
static |
Send out any buffered stats 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:
StatsFactory | $statsFactory | |
IBufferingStatsdDataFactory | $stats | |
Config | $config |
ConfigException |
Definition at line 726 of file MediaWikiEntryPoint.php.
References Wikimedia\Stats\IBufferingStatsdDataFactory\clearData(), Wikimedia\Stats\StatsFactory\flush(), MediaWiki\Config\Config\get(), Wikimedia\Stats\IBufferingStatsdDataFactory\getData(), Wikimedia\Stats\IBufferingStatsdDataFactory\getDataCount(), and Wikimedia\Stats\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 974 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 1264 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 1228 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 1054 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 866 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 1031 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 898 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 886 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 858 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an environment variable.
string | $name |
Definition at line 1179 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an ini option.
string | $name |
Definition at line 1192 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 878 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 854 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 862 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 995 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1128 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 850 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 890 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 442 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 1255 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 894 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 910 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 842 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 882 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 874 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 870 of file MediaWikiEntryPoint.php.
|
protected |
|
protected |
Definition at line 846 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 221 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 906 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1209 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 1157 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 902 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 568 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 454 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 165 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 914 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 655 of file MediaWikiEntryPoint.php.
References Profiler\instance(), and wfDebug().
|
final |
Main app life cycle: Calls doSetup(), execute(), prepareForOutput(), and postOutputShutdown().
Definition at line 197 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 235 of file MediaWikiEntryPoint.php.
|
protected |
string | $name | |
mixed | $value |
Definition at line 1202 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 134 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 520 of file MediaWikiEntryPoint.php.
References PROTO_HTTPS.
|
protected |
Adds a new output buffer level.
?callable | $callback |
Definition at line 938 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1216 of file MediaWikiEntryPoint.php.
|
protected |
int | $n | Number of jobs to try to run |
LoggerInterface | $runJobsLogger |
Definition at line 765 of file MediaWikiEntryPoint.php.
References $url.
|
protected |
Triggers a PHP runtime error.
Definition at line 1166 of file MediaWikiEntryPoint.php.
|
protected |
int | $n | Number of jobs to try to run |
Definition at line 754 of file MediaWikiEntryPoint.php.
References Profiler\instance().
|
protected |
Definition at line 101 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\__construct(), and MediaWiki\Api\ApiEntryPoint\__construct().