30 parent::__construct( $mainModule, $moduleName );
31 $this->mergeHistoryFactory = $mergeHistoryFactory;
43 if ( isset( $params[
'from'] ) ) {
44 $fromTitle = Title::newFromText( $params[
'from'] );
45 if ( !$fromTitle || $fromTitle->isExternal() ) {
48 } elseif ( isset( $params[
'fromid'] ) ) {
49 $fromTitle = Title::newFromID( $params[
'fromid'] );
51 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
57 if ( isset( $params[
'to'] ) ) {
58 $toTitle = Title::newFromText( $params[
'to'] );
59 if ( !$toTitle || $toTitle->isExternal() ) {
62 } elseif ( isset( $params[
'toid'] ) ) {
63 $toTitle = Title::newFromID( $params[
'toid'] );
65 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'toid'] ] );
71 $reason = $params[
'reason'];
72 $timestamp = $params[
'timestamp'] ??
'';
73 $startTimestamp = $params[
'starttimestamp'] ??
'';
76 $status = $this->
merge( $fromTitle, $toTitle, $timestamp, $reason, $startTimestamp );
77 if ( !$status->isOK() ) {
82 'from' => $fromTitle->getPrefixedText(),
83 'to' => $toTitle->getPrefixedText(),
84 'timestamp' => $params[
'timestamp'],
85 'reason' => $params[
'reason']
101 $mh = $this->mergeHistoryFactory->newMergeHistory( $from, $to, $timestamp, $startTimestamp );
121 ParamValidator::PARAM_TYPE =>
'integer'
125 ParamValidator::PARAM_TYPE =>
'integer'
130 'starttimestamp' => null
142 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
144 =>
'apihelp-mergehistory-example-merge',
145 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
146 'reason=Reason×tamp=2015-12-31T04%3A37%3A41Z'
147 =>
'apihelp-mergehistory-example-merge-timestamp',
153 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Mergehistory';
158class_alias( ApiMergeHistory::class,
'ApiMergeHistory' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This is the main API class, used for both external and internal processing.
API Module to merge page histories.
isWriteMode()
Indicates whether this module requires write access to the wiki.API modules must override this method...
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
__construct(ApiMain $mainModule, string $moduleName, MergeHistoryFactory $mergeHistoryFactory)
getHelpUrls()
Return links to more detailed help pages about the module.1.25, returning boolean false is deprecated...
merge(PageIdentity $from, PageIdentity $to, $timestamp, $reason, $startTimestamp)
mustBePosted()
Indicates whether this module must be called with a POST request.Implementations of this method must ...
needsToken()
Returns the token type this module requires in order to execute.Modules are strongly encouraged to us...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Service for mergehistory actions.
Interface for objects (potentially) representing an editable wiki page.