56 parent::__construct( $mainModule, $moduleName );
58 $this->movePageFactory = $movePageFactory;
59 $this->repoGroup = $repoGroup;
63 $this->watchlistMaxDuration =
65 $this->watchlistManager = $watchlistManager;
66 $this->watchedItemStore = $watchedItemStore;
67 $this->userOptionsLookup = $userOptionsLookup;
78 if ( isset( $params[
'from'] ) ) {
79 $fromTitle = Title::newFromText( $params[
'from'] );
80 if ( !$fromTitle || $fromTitle->isExternal() ) {
83 } elseif ( isset( $params[
'fromid'] ) ) {
84 $fromTitle = Title::newFromID( $params[
'fromid'] );
86 $this->
dieWithError( [
'apierror-nosuchpageid', $params[
'fromid'] ] );
89 throw new LogicException(
'Unreachable due to requireOnlyOneParameter' );
92 if ( !$fromTitle->exists() ) {
95 $fromTalk = $fromTitle->getTalkPage();
97 $toTitle = Title::newFromText( $params[
'to'] );
98 if ( !$toTitle || $toTitle->isExternal() ) {
101 $toTalk = $toTitle->getTalkPageIfDefined();
103 if ( $toTitle->getNamespace() ===
NS_FILE
104 && !$this->repoGroup->getLocalRepo()->findFile( $toTitle )
105 && $this->repoGroup->findFile( $toTitle )
107 if ( !$params[
'ignorewarnings'] &&
108 $this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
109 $this->
dieWithError(
'apierror-fileexists-sharedrepo-perm' );
110 } elseif ( !$this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
111 $this->
dieWithError(
'apierror-cantoverwrite-sharedfile' );
116 $toTitleExists = $toTitle->exists();
117 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
118 $status = $mp->moveIfAllowed(
121 !$params[
'noredirect'],
122 $params[
'tags'] ?: []
124 if ( !$status->isOK() ) {
129 'from' => $fromTitle->getPrefixedText(),
130 'to' => $toTitle->getPrefixedText(),
131 'reason' => $params[
'reason']
138 $r[
'redirectcreated'] = $fromTitle->exists();
140 $r[
'moveoverredirect'] = $toTitleExists;
143 if ( $params[
'movetalk'] && $toTalk && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
144 $toTalkExists = $toTalk->exists();
145 $mp = $this->movePageFactory->newMovePage( $fromTalk, $toTalk );
146 $status = $mp->moveIfAllowed(
149 !$params[
'noredirect'],
150 $params[
'tags'] ?: []
152 if ( $status->isOK() ) {
153 $r[
'talkfrom'] = $fromTalk->getPrefixedText();
154 $r[
'talkto'] = $toTalk->getPrefixedText();
155 $r[
'talkmoveoverredirect'] = $toTalkExists;
165 if ( $params[
'movesubpages'] ) {
170 $params[
'noredirect'],
171 $params[
'tags'] ?: []
175 if ( $params[
'movetalk'] && $toTalk ) {
180 $params[
'noredirect'],
181 $params[
'tags'] ?: []
187 $watch = $params[
'watchlist'] ??
'preferences';
192 $this->
setWatch( $watch, $fromTitle, $user,
'watchmoves', $watchlistExpiryFrom );
193 $this->
setWatch( $watch, $toTitle, $user,
'watchmoves', $watchlistExpiryTo );
206 public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) {
209 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
211 $mp->moveSubpagesIfAllowed( $this->
getAuthority(), $reason, !$noredirect, $changeTags );
212 if ( !$result->isOK() ) {
219 foreach ( $result->getValue() as $oldTitle => $status ) {
221 $r = [
'from' => $oldTitle ];
222 if ( $status->isOK() ) {
223 $r[
'to'] = $status->getValue();
245 ParamValidator::PARAM_TYPE =>
'integer'
248 ParamValidator::PARAM_TYPE =>
'string',
249 ParamValidator::PARAM_REQUIRED => true
253 'movesubpages' =>
false,
254 'noredirect' =>
false,
262 'ignorewarnings' =>
false,
264 ParamValidator::PARAM_TYPE =>
'tags',
265 ParamValidator::PARAM_ISMULTI =>
true,
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';
288class_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.