46 parent::__construct( $mainModule, $moduleName );
50 $this->watchlistExpiryEnabled = $this->
getConfig()->get(
'WatchlistExpiry' );
51 $this->watchlistMaxDuration = $this->
getConfig()->get(
'WatchlistExpiryMaxDuration' );
76 if ( $params[
'tags'] ) {
78 if ( !$tagStatus->isOK() ) {
85 $trxLimits = $this->
getConfig()->get(
'TrxProfilerLimits' );
86 $trxProfiler = Profiler::instance()->getTransactionProfiler();
87 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
88 DeferredUpdates::addCallableUpdate(
static function () use ( $trxProfiler, $trxLimits, $fname ) {
89 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
92 $rollbackResult = $this->rollbackPageFactory
94 ->setSummary( $params[
'summary'] )
95 ->markAsBot( $params[
'markbot'] )
96 ->setChangeTags( $params[
'tags'] )
97 ->rollbackIfAllowed();
99 if ( !$rollbackResult->isGood() ) {
103 $watch = $params[
'watchlist'] ??
'preferences';
107 $this->
setWatch( $watch, $titleObj, $user,
'watchrollback', $watchlistExpiry );
109 $details = $rollbackResult->getValue();
110 $currentRevisionRecord = $details[
'current-revision-record'];
111 $targetRevisionRecord = $details[
'target-revision-record'];
114 'title' => $titleObj->getPrefixedText(),
115 'pageid' => $currentRevisionRecord->getPageId(),
116 'summary' => $details[
'summary'],
117 'revid' => (int)$details[
'newid'],
119 'old_revid' => $currentRevisionRecord->getID(),
121 'last_revid' => $targetRevisionRecord->getID()
147 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
148 UserDef::PARAM_RETURN_OBJECT =>
true,
177 if ( $this->mUser !== null ) {
181 $this->mUser = $params[
'user'];
192 if ( $this->mTitleObj !==
null ) {
193 return $this->mTitleObj;
196 $this->requireOnlyOneParameter( $params,
'title',
'pageid' );
198 if ( isset( $params[
'title'] ) ) {
199 $this->mTitleObj = Title::newFromText( $params[
'title'] );
200 if ( !$this->mTitleObj || $this->mTitleObj->isExternal() ) {
201 $this->dieWithError( [
'apierror-invalidtitle',
wfEscapeWikiText( $params[
'title'] ) ] );
203 } elseif ( isset( $params[
'pageid'] ) ) {
204 $this->mTitleObj = Title::newFromID( $params[
'pageid'] );
205 if ( !$this->mTitleObj ) {
206 $this->dieWithError( [
'apierror-nosuchpageid', $params[
'pageid'] ] );
210 if ( !$this->mTitleObj->exists() ) {
211 $this->dieWithError(
'apierror-missingtitle' );
214 return $this->mTitleObj;
219 'action=rollback&title=Main%20Page&user=Example&token=123ABC' =>
220 'apihelp-rollback-example-simple',
221 'action=rollback&title=Main%20Page&user=192.0.2.5&' .
222 'token=123ABC&summary=Reverting%20vandalism&markbot=1' =>
223 'apihelp-rollback-example-summary',
228 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Rollback';
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.
WatchlistManager $watchlistManager
UserOptionsLookup $userOptionsLookup
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
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.
This is the main API class, used for both external and internal processing.
getRbTitle(array $params)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
isWriteMode()
Indicates whether this module requires write mode.
RollbackPageFactory $rollbackPageFactory
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiMain $mainModule, $moduleName, RollbackPageFactory $rollbackPageFactory, WatchlistManager $watchlistManager, UserOptionsLookup $userOptionsLookup)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
mustBePosted()
Indicates whether this module must be called with a POST request.
needsToken()
Returns the token type this module requires in order to execute.
Represents a title within MediaWiki.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...