38 if ( isset( $params[
'from'] ) ) {
39 $fromTitle = Title::newFromText( $params[
'from'] );
40 if ( !$fromTitle || $fromTitle->isExternal() ) {
43 } elseif ( isset( $params[
'fromid'] ) ) {
44 $fromTitle = Title::newFromID( $params[
'fromid'] );
46 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
50 if ( isset( $params[
'to'] ) ) {
51 $toTitle = Title::newFromText( $params[
'to'] );
52 if ( !$toTitle || $toTitle->isExternal() ) {
55 } elseif ( isset( $params[
'toid'] ) ) {
56 $toTitle = Title::newFromID( $params[
'toid'] );
58 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'toid'] ] );
62 $reason = $params[
'reason'];
63 $timestamp = $params[
'timestamp'];
66 $status = $this->
merge( $fromTitle, $toTitle, $timestamp, $reason );
67 if ( !$status->isOK() ) {
72 'from' => $fromTitle->getPrefixedText(),
73 'to' => $toTitle->getPrefixedText(),
74 'timestamp' =>
wfTimestamp( TS_ISO_8601, $params[
'timestamp'] ),
75 'reason' => $params[
'reason']
92 return $mh->merge( $this->
getUser(), $reason );
126 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
128 =>
'apihelp-mergehistory-example-merge',
129 'action=mergehistory&from=Oldpage&to=Newpage&token=123ABC&' .
130 'reason=Reason×tamp=2015-12-31T04%3A37%3A41Z'
131 =>
'apihelp-mergehistory-example-merge-timestamp',
136 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=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
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.
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
API Module to merge page histories.
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
merge(Title $from, Title $to, $timestamp, $reason)
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...
Handles the backend logic of merging the histories of two pages.
Represents a title within MediaWiki.