39 parent::__construct( $mainModule, $moduleName );
43 $this->watchlistMaxDuration =
45 $this->watchlistManager = $watchlistManager;
46 $this->watchedItemStore = $watchedItemStore;
47 $this->userOptionsLookup = $userOptionsLookup;
58 if ( isset( $params[
'from'] ) ) {
59 $fromTitle = Title::newFromText( $params[
'from'] );
60 if ( !$fromTitle || $fromTitle->isExternal() ) {
63 } elseif ( isset( $params[
'fromid'] ) ) {
64 $fromTitle = Title::newFromID( $params[
'fromid'] );
66 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
69 throw new LogicException(
'Unreachable due to requireOnlyOneParameter' );
72 if ( !$fromTitle->exists() ) {
75 $fromTalk = $fromTitle->getTalkPage();
77 $toTitle = Title::newFromText( $params[
'to'] );
78 if ( !$toTitle || $toTitle->isExternal() ) {
81 $toTalk = $toTitle->getTalkPageIfDefined();
83 if ( $toTitle->getNamespace() ===
NS_FILE
84 && !$this->repoGroup->getLocalRepo()->findFile( $toTitle )
85 && $this->repoGroup->findFile( $toTitle )
87 if ( !$params[
'ignorewarnings'] &&
88 $this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
89 $this->
dieWithError(
'apierror-fileexists-sharedrepo-perm' );
90 } elseif ( !$this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
91 $this->
dieWithError(
'apierror-cantoverwrite-sharedfile' );
96 $toTitleExists = $toTitle->exists();
97 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
98 $status = $mp->moveIfAllowed(
101 !$params[
'noredirect'],
102 $params[
'tags'] ?: []
104 if ( !$status->isOK() ) {
109 'from' => $fromTitle->getPrefixedText(),
110 'to' => $toTitle->getPrefixedText(),
111 'reason' => $params[
'reason']
118 $r[
'redirectcreated'] = $fromTitle->exists();
120 $r[
'moveoverredirect'] = $toTitleExists;
123 if ( $params[
'movetalk'] && $toTalk && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
124 $toTalkExists = $toTalk->exists();
125 $mp = $this->movePageFactory->newMovePage( $fromTalk, $toTalk );
126 $status = $mp->moveIfAllowed(
129 !$params[
'noredirect'],
130 $params[
'tags'] ?: []
132 if ( $status->isOK() ) {
133 $r[
'talkfrom'] = $fromTalk->getPrefixedText();
134 $r[
'talkto'] = $toTalk->getPrefixedText();
135 $r[
'talkmoveoverredirect'] = $toTalkExists;
145 if ( $params[
'movesubpages'] ) {
150 $params[
'noredirect'],
151 $params[
'tags'] ?: []
155 if ( $params[
'movetalk'] && $toTalk ) {
160 $params[
'noredirect'],
161 $params[
'tags'] ?: []
167 $watch = $params[
'watchlist'] ??
'preferences';
172 $this->
setWatch( $watch, $fromTitle, $user,
'watchmoves', $watchlistExpiryFrom );
173 $this->
setWatch( $watch, $toTitle, $user,
'watchmoves', $watchlistExpiryTo );
186 public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) {
189 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
191 $mp->moveSubpagesIfAllowed( $this->
getAuthority(), $reason, !$noredirect, $changeTags );
192 if ( !$result->isOK() ) {
199 foreach ( $result->getValue() as $oldTitle => $status ) {
201 $r = [
'from' => $oldTitle ];
202 if ( $status->isOK() ) {
203 $r[
'to'] = $status->getValue();
228 ParamValidator::PARAM_TYPE =>
'integer'
231 ParamValidator::PARAM_TYPE =>
'string',
232 ParamValidator::PARAM_REQUIRED => true
236 'movesubpages' =>
false,
237 'noredirect' =>
false,
245 'ignorewarnings' =>
false,
247 ParamValidator::PARAM_TYPE =>
'tags',
248 ParamValidator::PARAM_ISMULTI =>
true,
261 'action=move&from=Badtitle&to=Goodtitle&token=123ABC&' .
262 'reason=Misspelled%20title&movetalk=&noredirect='
263 =>
'apihelp-move-example-move',
269 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Move';
274class_alias( ApiMove::class,
'ApiMove' );
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.
A class containing constants representing the names of configuration variables.
const WatchlistExpiry
Name constant for the WatchlistExpiry setting, for use with Config::get()
const WatchlistExpiryMaxDuration
Name constant for the WatchlistExpiryMaxDuration setting, for use with Config::get()
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...
Service for page rename actions.