|
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) |
| 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 (string $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 |
| MediaWikiServices | $mediaWikiServices |
Base class for entry point handlers.
Definition at line 60 of file MediaWikiEntryPoint.php.
| MediaWiki\MediaWikiEntryPoint::__construct | ( | IContextSource | $context, |
| EntryPointEnvironment | $environment, | ||
| MediaWikiServices | $mediaWikiServices ) |
| IContextSource | $context | |
| EntryPointEnvironment | $environment | |
| MediaWikiServices | $mediaWikiServices |
Definition at line 90 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 261 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 966 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1101 of file MediaWikiEntryPoint.php.
|
protected |
Discards all buffered output, down to the capture buffer level.
Definition at line 1069 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1097 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 452 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 165 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 128 of file MediaWikiEntryPoint.php.
|
protected |
Returns the content of the current output buffer and clears it.
Definition at line 910 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 |
Definition at line 700 of file MediaWikiEntryPoint.php.
References Wikimedia\Stats\StatsFactory\flush().
| 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 936 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 1226 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 1190 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 1016 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 820 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 993 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 855 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 840 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 812 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an environment variable.
| string | $name |
Definition at line 1141 of file MediaWikiEntryPoint.php.
|
protected |
Returns the value of an ini option.
| string | $name |
Definition at line 1154 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 832 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 808 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 816 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 957 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1090 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 804 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 844 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 420 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 1217 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 848 of file MediaWikiEntryPoint.php.
|
protected |
| string | $key | |
| mixed | null | $default |
Definition at line 872 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 796 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 836 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 828 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 824 of file MediaWikiEntryPoint.php.
|
protected |
|
protected |
Definition at line 800 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.
Reimplemented in MediaWiki\Actions\ActionEntryPoint.
Definition at line 199 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 863 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1171 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 1119 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 859 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 546 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 432 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 145 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\FileRepo\AuthenticatedFileEntryPoint\execute().
|
protected |
Definition at line 876 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 633 of file MediaWikiEntryPoint.php.
References Profiler\instance(), and wfDebug().
|
final |
Main app life cycle: Calls doSetup(), execute(), prepareForOutput(), and postOutputShutdown().
Definition at line 177 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 213 of file MediaWikiEntryPoint.php.
|
protected |
| string | $name | |
| mixed | $value |
Definition at line 1164 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 114 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 498 of file MediaWikiEntryPoint.php.
References PROTO_HTTPS.
|
protected |
Adds a new output buffer level.
| ?callable | $callback |
Definition at line 900 of file MediaWikiEntryPoint.php.
|
protected |
Definition at line 1178 of file MediaWikiEntryPoint.php.
|
protected |
| int | $n | Number of jobs to try to run |
| LoggerInterface | $runJobsLogger |
Definition at line 721 of file MediaWikiEntryPoint.php.
References $url.
|
protected |
Triggers a PHP runtime error.
Definition at line 1128 of file MediaWikiEntryPoint.php.
|
protected |
| int | $n | Number of jobs to try to run |
Definition at line 710 of file MediaWikiEntryPoint.php.
References Profiler\instance().
|
protected |
Definition at line 81 of file MediaWikiEntryPoint.php.
Referenced by MediaWiki\__construct(), and MediaWiki\Api\ApiEntryPoint\__construct().
|
protected |
Definition at line 83 of file MediaWikiEntryPoint.php.