Go to the documentation of this file.
39 if ( isset( $params[
'from'] ) ) {
41 if ( !$fromTitle || $fromTitle->isExternal() ) {
44 } elseif ( isset( $params[
'fromid'] ) ) {
47 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
51 if ( !$fromTitle->exists() ) {
54 $fromTalk = $fromTitle->getTalkPage();
57 if ( !$toTitle || $toTitle->isExternal() ) {
60 $toTalk = $toTitle->getTalkPageIfDefined();
62 $repoGroup = MediaWikiServices::getInstance()->getRepoGroup();
63 if ( $toTitle->getNamespace() ==
NS_FILE
64 && !$repoGroup->getLocalRepo()->findFile( $toTitle )
65 && $repoGroup->findFile( $toTitle )
67 if ( !$params[
'ignorewarnings'] &&
69 $this->
dieWithError(
'apierror-fileexists-sharedrepo-perm' );
71 $this->
dieWithError(
'apierror-cantoverwrite-sharedfile' );
76 if ( $user->pingLimiter(
'move' ) ) {
81 if ( $params[
'tags'] ) {
83 if ( !$ableToTag->isOK() ) {
89 $toTitleExists = $toTitle->exists();
90 $status = $this->
movePage( $fromTitle, $toTitle, $params[
'reason'], !$params[
'noredirect'],
91 $params[
'tags'] ?: [] );
93 $user->spreadAnyEditBlock();
98 'from' => $fromTitle->getPrefixedText(),
99 'to' => $toTitle->getPrefixedText(),
100 'reason' => $params[
'reason']
107 $r[
'redirectcreated'] = $fromTitle->exists();
109 $r[
'moveoverredirect'] = $toTitleExists;
112 if ( $params[
'movetalk'] && $toTalk && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
113 $toTalkExists = $toTalk->exists();
118 !$params[
'noredirect'],
119 $params[
'tags'] ?: []
122 $r[
'talkfrom'] = $fromTalk->getPrefixedText();
123 $r[
'talkto'] = $toTalk->getPrefixedText();
124 $r[
'talkmoveoverredirect'] = $toTalkExists;
134 if ( $params[
'movesubpages'] ) {
139 $params[
'noredirect'],
140 $params[
'tags'] ?: []
144 if ( $params[
'movetalk'] ) {
149 $params[
'noredirect'],
150 $params[
'tags'] ?: []
156 $watch =
'preferences';
157 if ( isset( $params[
'watchlist'] ) ) {
158 $watch = $params[
'watchlist'];
162 $this->
setWatch( $watch, $fromTitle,
'watchmoves' );
163 $this->
setWatch( $watch, $toTitle,
'watchmoves' );
177 $mp = MediaWikiServices::getInstance()->getMovePageFactory()->newMovePage( $from, $to );
178 $valid = $mp->isValidMove();
179 if ( !$valid->isOK() ) {
184 $permStatus = $mp->checkPermissions( $user, $reason );
185 if ( !$permStatus->isOK() ) {
191 $createRedirect =
true;
194 return $mp->move( $user, $reason, $createRedirect, $changeTags );
205 public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) {
208 $mp =
new MovePage( $fromTitle, $toTitle );
210 $mp->moveSubpagesIfAllowed( $this->
getUser(), $reason, !$noredirect, $changeTags );
211 if ( !$result->isOK() ) {
218 foreach ( $result->getValue() as $oldTitle =>
$status ) {
219 $r = [
'from' => $oldTitle ];
221 $r[
'to'] =
$status->getValue();
251 'movesubpages' =>
false,
252 'noredirect' =>
false,
262 'ignorewarnings' =>
false,
276 'action=move&from=Badtitle&to=Goodtitle&token=123ABC&' .
277 'reason=Misspelled%20title&movetalk=&noredirect='
278 =>
'apihelp-move-example-move',
283 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Move';
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
const PARAM_REQUIRED
(boolean) Is the parameter required?
needsToken()
Returns the token type this module requires in order to execute.
moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags=[])
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.
This abstract class implements many basic API functions, and is the base of all API classes.
movePage(Title $from, Title $to, $reason, $createRedirect, $changeTags)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Handles the backend logic of moving a page from one title to another.
isWriteMode()
Indicates whether this module requires write mode.
getExamplesMessages()
Returns usage examples for this module.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
API Module to move pages.
setWatch( $watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
getHelpUrls()
Return links to more detailed help pages about the module.
Represents a title within MediaWiki.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
mustBePosted()
Indicates whether this module must be called with a POST request.
getErrorFormatter()
Get the error formatter.