35 private $mergeHistoryFactory;
47 parent::__construct( $mainModule, $moduleName );
48 $this->mergeHistoryFactory = $mergeHistoryFactory;
60 if ( isset( $params[
'from'] ) ) {
61 $fromTitle = Title::newFromText( $params[
'from'] );
62 if ( !$fromTitle || $fromTitle->isExternal() ) {
65 } elseif ( isset( $params[
'fromid'] ) ) {
66 $fromTitle = Title::newFromID( $params[
'fromid'] );
68 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
72 if ( isset( $params[
'to'] ) ) {
73 $toTitle = Title::newFromText( $params[
'to'] );
74 if ( !$toTitle || $toTitle->isExternal() ) {
77 } elseif ( isset( $params[
'toid'] ) ) {
78 $toTitle = Title::newFromID( $params[
'toid'] );
80 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'toid'] ] );
84 $reason = $params[
'reason'];
85 $timestamp = $params[
'timestamp'];
89 $status = $this->
merge( $fromTitle, $toTitle, $timestamp, $reason );
90 if ( !$status->isOK() ) {
96 'from' => $fromTitle->getPrefixedText(),
98 'to' => $toTitle->getPrefixedText(),
99 'timestamp' =>
wfTimestamp( TS_ISO_8601, $params[
'timestamp'] ),
100 'reason' => $params[
'reason']
115 $mh = $this->mergeHistoryFactory->newMergeHistory( $from, $to, $timestamp );
132 ParamValidator::PARAM_TYPE =>
'integer'
136 ParamValidator::PARAM_TYPE =>
'integer'
139 ParamValidator::PARAM_TYPE =>
'timestamp'
151 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
153 =>
'apihelp-mergehistory-example-merge',
154 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
155 'reason=Reason×tamp=2015-12-31T04%3A37%3A41Z'
156 =>
'apihelp-mergehistory-example-merge-timestamp',
161 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Mergehistory';
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.
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
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.
API Module to merge page histories.
__construct(ApiMain $mainModule, $moduleName, MergeHistoryFactory $mergeHistoryFactory)
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
isWriteMode()
Indicates whether this module requires write mode.
needsToken()
Returns the token type this module requires in order to execute.
mustBePosted()
Indicates whether this module must be called with a POST request.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
merge(PageIdentity $from, PageIdentity $to, $timestamp, $reason)
Service for mergehistory actions.
Interface for objects (potentially) representing an editable wiki page.