54 parent::__construct( $mainModule, $moduleName );
56 $this->movePageFactory = $movePageFactory;
57 $this->repoGroup = $repoGroup;
61 $this->watchlistMaxDuration =
63 $this->watchlistManager = $watchlistManager;
64 $this->userOptionsLookup = $userOptionsLookup;
75 if ( isset(
$params[
'from'] ) ) {
76 $fromTitle = Title::newFromText(
$params[
'from'] );
77 if ( !$fromTitle || $fromTitle->isExternal() ) {
80 } elseif ( isset(
$params[
'fromid'] ) ) {
81 $fromTitle = Title::newFromID(
$params[
'fromid'] );
86 throw new LogicException(
'Unreachable due to requireOnlyOneParameter' );
89 if ( !$fromTitle->exists() ) {
92 $fromTalk = $fromTitle->getTalkPage();
94 $toTitle = Title::newFromText(
$params[
'to'] );
95 if ( !$toTitle || $toTitle->isExternal() ) {
98 $toTalk = $toTitle->getTalkPageIfDefined();
100 if ( $toTitle->getNamespace() ===
NS_FILE
101 && !$this->repoGroup->getLocalRepo()->findFile( $toTitle )
102 && $this->repoGroup->findFile( $toTitle )
104 if ( !
$params[
'ignorewarnings'] &&
105 $this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
106 $this->
dieWithError(
'apierror-fileexists-sharedrepo-perm' );
107 } elseif ( !$this->
getAuthority()->isAllowed(
'reupload-shared' ) ) {
108 $this->
dieWithError(
'apierror-cantoverwrite-sharedfile' );
113 $toTitleExists = $toTitle->exists();
114 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
115 $status = $mp->moveIfAllowed(
121 if ( !$status->isOK() ) {
126 'from' => $fromTitle->getPrefixedText(),
127 'to' => $toTitle->getPrefixedText(),
135 $r[
'redirectcreated'] = $fromTitle->exists();
137 $r[
'moveoverredirect'] = $toTitleExists;
140 if (
$params[
'movetalk'] && $toTalk && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
141 $toTalkExists = $toTalk->exists();
142 $mp = $this->movePageFactory->newMovePage( $fromTalk, $toTalk );
143 $status = $mp->moveIfAllowed(
149 if ( $status->isOK() ) {
150 $r[
'talkfrom'] = $fromTalk->getPrefixedText();
151 $r[
'talkto'] = $toTalk->getPrefixedText();
152 $r[
'talkmoveoverredirect'] = $toTalkExists;
162 if (
$params[
'movesubpages'] ) {
172 if (
$params[
'movetalk'] && $toTalk ) {
184 $watch =
$params[
'watchlist'] ??
'preferences';
188 $this->
setWatch( $watch, $fromTitle, $user,
'watchmoves', $watchlistExpiry );
189 $this->
setWatch( $watch, $toTitle, $user,
'watchmoves', $watchlistExpiry );
202 public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) {
205 $mp = $this->movePageFactory->newMovePage( $fromTitle, $toTitle );
207 $mp->moveSubpagesIfAllowed( $this->
getAuthority(), $reason, !$noredirect, $changeTags );
208 if ( !$result->isOK() ) {
215 foreach ( $result->getValue() as $oldTitle => $status ) {
217 $r = [
'from' => $oldTitle ];
218 if ( $status->isOK() ) {
219 $r[
'to'] = $status->getValue();
241 ParamValidator::PARAM_TYPE =>
'integer'
244 ParamValidator::PARAM_TYPE =>
'string',
245 ParamValidator::PARAM_REQUIRED => true
249 'movesubpages' =>
false,
250 'noredirect' =>
false,
258 'ignorewarnings' =>
false,
260 ParamValidator::PARAM_TYPE =>
'tags',
261 ParamValidator::PARAM_ISMULTI =>
true,
272 'action=move&from=Badtitle&to=Goodtitle&token=123ABC&' .
273 'reason=Misspelled%20title&movetalk=&noredirect='
274 =>
'apihelp-move-example-move',
279 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Move';
284class_alias( ApiMove::class,
'ApiMove' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
array $params
The job parameters.
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()
Prioritized list of file repositories.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...
Service for page rename actions.