31 parent::__construct( $mainModule, $moduleName, $modulePrefix );
33 $this->watchlistExpiryEnabled = $this->
getConfig()->get(
'WatchlistExpiry' );
34 $this->watchlistMaxDuration = $this->
getConfig()->get(
'WatchlistExpiryMaxDuration' );
43 $block = $user->getBlock();
44 if ( $block && $block->isSitewide() ) {
48 $titleObj = Title::newFromText( $params[
'title'] );
49 if ( !$titleObj || $titleObj->isExternal() ) {
58 if ( $params[
'tags'] !==
null ) {
60 if ( !$ableToTag->isOK() ) {
66 if ( !isset( $params[
'timestamps'] ) ) {
67 $params[
'timestamps'] = [];
69 if ( !is_array( $params[
'timestamps'] ) ) {
70 $params[
'timestamps'] = [ $params[
'timestamps'] ];
72 foreach ( $params[
'timestamps'] as $i => $ts ) {
73 $params[
'timestamps'][$i] =
wfTimestamp( TS_MW, $ts );
77 $retval = $pa->undeleteAsUser(
78 ( $params[
'timestamps'] ?? [] ),
85 if ( !is_array( $retval ) ) {
91 $titleObj, $params[
'fileids'],
92 $this->
getUser(), $params[
'reason'] );
96 $this->
setWatch( $params[
'watchlist'], $titleObj, $user,
null, $watchlistExpiry );
99 'title' => $titleObj->getPrefixedText(),
100 'revisions' => (int)$retval[0],
101 'fileversions' => (
int)$retval[1],
102 'reason' => $retval[2]
143 'action=undelete&title=Main%20Page&token=123ABC&reason=Restoring%20main%20page'
144 =>
'apihelp-undelete-example-page',
145 'action=undelete&title=Main%20Page&token=123ABC' .
146 '×tamps=2007-07-03T22:00:45Z|2007-07-02T19:48:56Z'
147 =>
'apihelp-undelete-example-revisions',
152 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Undelete';
getExpiryFromParams(array $params)
Get formatted expiry from the given parameters, or null if no expiry was provided.
setWatch(string $watch, Title $title, User $user, ?string $userOption=null, ?string $expiry=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
getWatchlistParams(array $watchOptions=[])
Get additional allow params specific to watchlisting.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This is the main API class, used for both external and internal processing.
needsToken()
Returns the token type this module requires in order to execute.
mustBePosted()
Indicates whether this module must be called with a POST request Stable to override.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiMain $mainModule, $moduleName, $modulePrefix='')
Stable to call.
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isWriteMode()
Indicates whether this module requires write mode.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getUser()
Stable to override.
Used to show archived pages and eventually restore them.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...