3 * Implements Special:Movepage
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 use MediaWiki\MediaWikiServices
;
27 * A special page that allows users to change page titles
29 * @ingroup SpecialPage
31 class MovePageForm
extends UnlistedSpecialPage
{
33 protected $oldTitle = null;
38 /** @var string Text input */
47 protected $deleteAndMove;
50 protected $moveSubpages;
53 protected $fixRedirects;
56 protected $leaveRedirect;
59 protected $moveOverShared;
61 private $watch = false;
63 public function __construct() {
64 parent
::__construct( 'Movepage' );
67 public function doesWrites() {
71 public function execute( $par ) {
72 $this->useTransactionalTimeLimit();
74 $this->checkReadOnly();
77 $this->outputHeader();
79 $request = $this->getRequest();
80 $target = $par ??
$request->getVal( 'target' );
82 // Yes, the use of getVal() and getText() is wanted, see T22365
84 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
85 $this->oldTitle
= Title
::newFromText( $oldTitleText );
87 if ( !$this->oldTitle
) {
88 // Either oldTitle wasn't passed, or newFromText returned null
89 throw new ErrorPageError( 'notargettitle', 'notargettext' );
91 if ( !$this->oldTitle
->exists() ) {
92 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
95 $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
96 $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle
->getNamespace() );
97 // Backwards compatibility for forms submitting here from other sources
98 // which is more common than it should be..
99 $newTitleText_bc = $request->getText( 'wpNewTitle' );
100 $this->newTitle
= strlen( $newTitleText_bc ) > 0
101 ? Title
::newFromText( $newTitleText_bc )
102 : Title
::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
104 $user = $this->getUser();
107 $permErrors = $this->oldTitle
->getUserPermissionsErrors( 'move', $user );
108 if ( count( $permErrors ) ) {
109 // Auto-block user's IP if the account was "hard" blocked
110 DeferredUpdates
::addCallableUpdate( function () use ( $user ) {
111 $user->spreadAnyEditBlock();
113 throw new PermissionsError( 'move', $permErrors );
116 $def = !$request->wasPosted();
118 $this->reason
= $request->getText( 'wpReason' );
119 $this->moveTalk
= $request->getBool( 'wpMovetalk', $def );
120 $this->fixRedirects
= $request->getBool( 'wpFixRedirects', $def );
121 $this->leaveRedirect
= $request->getBool( 'wpLeaveRedirect', $def );
122 $this->moveSubpages
= $request->getBool( 'wpMovesubpages' );
123 $this->deleteAndMove
= $request->getBool( 'wpDeleteAndMove' );
124 $this->moveOverShared
= $request->getBool( 'wpMoveOverSharedFile' );
125 $this->watch
= $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
127 if ( $request->getVal( 'action' ) == 'submit' && $request->wasPosted()
128 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
132 $this->showForm( [] );
139 * @param array $err Error messages. Each item is an error message.
140 * It may either be a string message name or array message name and
141 * parameters, like the second argument to OutputPage::wrapWikiMsg().
142 * @param bool $isPermError Whether the error message is about user permissions.
144 function showForm( $err, $isPermError = false ) {
145 $this->getSkin()->setRelevantTitle( $this->oldTitle
);
147 $out = $this->getOutput();
148 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle
->getPrefixedText() ) );
149 $out->addModuleStyles( 'mediawiki.special' );
150 $out->addModules( 'mediawiki.misc-authed-ooui' );
151 $this->addHelpLink( 'Help:Moving a page' );
153 $handlerSupportsRedirects = ContentHandler
::getForTitle( $this->oldTitle
)
154 ->supportsRedirects();
156 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
157 $out->addWikiMsg( 'movepagetext' );
159 $out->addWikiMsg( $handlerSupportsRedirects ?
160 'movepagetext-noredirectfixer' :
161 'movepagetext-noredirectsupport' );
164 if ( $this->oldTitle
->getNamespace() == NS_USER
&& !$this->oldTitle
->isSubpage() ) {
166 "<div class=\"warningbox mw-moveuserpage-warning\">\n$1\n</div>",
167 'moveuserpage-warning'
169 } elseif ( $this->oldTitle
->getNamespace() == NS_CATEGORY
) {
171 "<div class=\"warningbox mw-movecategorypage-warning\">\n$1\n</div>",
172 'movecategorypage-warning'
176 $deleteAndMove = false;
177 $moveOverShared = false;
179 $user = $this->getUser();
181 $newTitle = $this->newTitle
;
184 # Show the current title as a default
185 # when the form is first opened.
186 $newTitle = $this->oldTitle
;
187 } elseif ( !count( $err ) ) {
188 # If a title was supplied, probably from the move log revert
189 # link, check for validity. We can then show some diagnostic
190 # information and save a click.
191 $mp = new MovePage( $this->oldTitle
, $newTitle );
192 $status = $mp->isValidMove();
193 $status->merge( $mp->checkPermissions( $user, null ) );
194 if ( $status->getErrors() ) {
195 $err = $status->getErrorsArray();
199 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
200 && MediaWikiServices
::getInstance()->getPermissionManager()
201 ->quickUserCan( 'delete', $user, $newTitle )
204 "<div class='warningbox'>\n$1\n</div>\n",
205 [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
207 $deleteAndMove = true;
211 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
212 && MediaWikiServices
::getInstance()
213 ->getPermissionManager()
214 ->userHasRight( $user, 'reupload-shared' )
217 "<div class='warningbox'>\n$1\n</div>\n",
219 'move-over-sharedrepo',
220 $newTitle->getPrefixedText()
223 $moveOverShared = true;
227 $oldTalk = $this->oldTitle
->getTalkPage();
228 $oldTitleSubpages = $this->oldTitle
->hasSubpages();
229 $oldTitleTalkSubpages = $this->oldTitle
->getTalkPage()->hasSubpages();
231 $canMoveSubpage = ( $oldTitleSubpages ||
$oldTitleTalkSubpages ) &&
232 !count( $this->oldTitle
->getUserPermissionsErrors( 'move-subpages', $user ) );
234 # We also want to be able to move assoc. subpage talk-pages even if base page
235 # has no associated talk page, so || with $oldTitleTalkSubpages.
236 $considerTalk = !$this->oldTitle
->isTalkPage() &&
238 ||
( $oldTitleTalkSubpages && $canMoveSubpage ) );
240 $dbr = wfGetDB( DB_REPLICA
);
241 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
242 $hasRedirects = $dbr->selectField( 'redirect', '1',
244 'rd_namespace' => $this->oldTitle
->getNamespace(),
245 'rd_title' => $this->oldTitle
->getDBkey(),
248 $hasRedirects = false;
251 if ( count( $err ) ) {
252 if ( $isPermError ) {
253 $action_desc = $this->msg( 'action-move' )->plain();
254 $errMsgHtml = $this->msg( 'permissionserrorstext-withaction',
255 count( $err ), $action_desc )->parseAsBlock();
257 $errMsgHtml = $this->msg( 'cannotmove', count( $err ) )->parseAsBlock();
260 if ( count( $err ) == 1 ) {
262 $errMsgName = array_shift( $errMsg );
264 if ( $errMsgName == 'hookaborted' ) {
265 $errMsgHtml .= "<p>{$errMsg[0]}</p>\n";
267 $errMsgHtml .= $this->msg( $errMsgName, $errMsg )->parseAsBlock();
272 foreach ( $err as $errMsg ) {
273 if ( $errMsg[0] == 'hookaborted' ) {
274 $errStr[] = $errMsg[1];
276 $errMsgName = array_shift( $errMsg );
277 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
281 $errMsgHtml .= '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n";
283 $out->addHTML( Html
::errorBox( $errMsgHtml ) );
286 if ( $this->oldTitle
->isProtected( 'move' ) ) {
287 # Is the title semi-protected?
288 if ( $this->oldTitle
->isSemiProtected( 'move' ) ) {
289 $noticeMsg = 'semiprotectedpagemovewarning';
291 # Then it must be protected based on static groups (regular)
292 $noticeMsg = 'protectedpagemovewarning';
294 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
295 $out->addWikiMsg( $noticeMsg );
296 LogEventsList
::showLogExtract(
303 $out->addHTML( "</div>\n" );
306 // Length limit for wpReason and wpNewTitleMain is enforced in the
307 // mediawiki.special.movePage module
309 $immovableNamespaces = [];
310 $namespaceInfo = MediaWikiServices
::getInstance()->getNamespaceInfo();
311 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
312 if ( !$namespaceInfo->isMovable( $nsId ) ) {
313 $immovableNamespaces[] = $nsId;
320 $fields[] = new OOUI\
FieldLayout(
321 new MediaWiki\Widget\
ComplexTitleInputWidget( [
322 'id' => 'wpNewTitle',
324 'id' => 'wpNewTitleNs',
325 'name' => 'wpNewTitleNs',
326 'value' => $newTitle->getNamespace(),
327 'exclude' => $immovableNamespaces,
330 'id' => 'wpNewTitleMain',
331 'name' => 'wpNewTitleMain',
332 'value' => $newTitle->getText(),
333 // Inappropriate, since we're expecting the user to input a non-existent page's title
334 'suggestions' => false,
339 'label' => $this->msg( 'newtitle' )->text(),
344 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
345 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
346 // Unicode codepoints.
347 $fields[] = new OOUI\
FieldLayout(
348 new OOUI\
TextInputWidget( [
349 'name' => 'wpReason',
351 'maxLength' => CommentStore
::COMMENT_CHARACTER_LIMIT
,
353 'value' => $this->reason
,
356 'label' => $this->msg( 'movereason' )->text(),
361 if ( $considerTalk ) {
362 $fields[] = new OOUI\
FieldLayout(
363 new OOUI\
CheckboxInputWidget( [
364 'name' => 'wpMovetalk',
365 'id' => 'wpMovetalk',
367 'selected' => $this->moveTalk
,
370 'label' => $this->msg( 'movetalk' )->text(),
371 'help' => new OOUI\
HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
372 'helpInline' => true,
374 'id' => 'wpMovetalk-field',
379 if ( MediaWikiServices
::getInstance()
380 ->getPermissionManager()
381 ->userHasRight( $user, 'suppressredirect' )
383 if ( $handlerSupportsRedirects ) {
384 $isChecked = $this->leaveRedirect
;
390 $fields[] = new OOUI\
FieldLayout(
391 new OOUI\
CheckboxInputWidget( [
392 'name' => 'wpLeaveRedirect',
393 'id' => 'wpLeaveRedirect',
395 'selected' => $isChecked,
396 'disabled' => $isDisabled,
399 'label' => $this->msg( 'move-leave-redirect' )->text(),
405 if ( $hasRedirects ) {
406 $fields[] = new OOUI\
FieldLayout(
407 new OOUI\
CheckboxInputWidget( [
408 'name' => 'wpFixRedirects',
409 'id' => 'wpFixRedirects',
411 'selected' => $this->fixRedirects
,
414 'label' => $this->msg( 'fix-double-redirects' )->text(),
420 if ( $canMoveSubpage ) {
421 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
422 $fields[] = new OOUI\
FieldLayout(
423 new OOUI\
CheckboxInputWidget( [
424 'name' => 'wpMovesubpages',
425 'id' => 'wpMovesubpages',
427 'selected' => true, // T222953 Always check the box
430 'label' => new OOUI\
HtmlSnippet(
432 ( $this->oldTitle
->hasSubpages()
434 : 'move-talk-subpages' )
435 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
442 # Don't allow watching if user is not logged in
443 if ( $user->isLoggedIn() ) {
444 $watchChecked = $user->isLoggedIn() && ( $this->watch ||
$user->getBoolOption( 'watchmoves' )
445 ||
$user->isWatched( $this->oldTitle
) );
446 $fields[] = new OOUI\
FieldLayout(
447 new OOUI\
CheckboxInputWidget( [
449 'id' => 'watch', # ew
451 'selected' => $watchChecked,
454 'label' => $this->msg( 'move-watch' )->text(),
461 if ( $moveOverShared ) {
462 $hiddenFields .= Html
::hidden( 'wpMoveOverSharedFile', '1' );
465 if ( $deleteAndMove ) {
466 $fields[] = new OOUI\
FieldLayout(
467 new OOUI\
CheckboxInputWidget( [
468 'name' => 'wpDeleteAndMove',
469 'id' => 'wpDeleteAndMove',
473 'label' => $this->msg( 'delete_and_move_confirm' )->text(),
479 $fields[] = new OOUI\
FieldLayout(
480 new OOUI\
ButtonInputWidget( [
482 'value' => $this->msg( 'movepagebtn' )->text(),
483 'label' => $this->msg( 'movepagebtn' )->text(),
484 'flags' => [ 'primary', 'progressive' ],
492 $fieldset = new OOUI\
FieldsetLayout( [
493 'label' => $this->msg( 'move-page-legend' )->text(),
494 'id' => 'mw-movepage-table',
498 $form = new OOUI\
FormLayout( [
500 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
503 $form->appendContent(
505 new OOUI\
HtmlSnippet(
507 Html
::hidden( 'wpOldTitle', $this->oldTitle
->getPrefixedText() ) .
508 Html
::hidden( 'wpEditToken', $user->getEditToken() )
513 new OOUI\
PanelLayout( [
514 'classes' => [ 'movepage-wrapper' ],
522 $this->showLogFragment( $this->oldTitle
);
523 $this->showSubpages( $this->oldTitle
);
526 function doSubmit() {
527 $user = $this->getUser();
528 $permissionManager = MediaWikiServices
::getInstance()->getPermissionManager();
530 if ( $user->pingLimiter( 'move' ) ) {
531 throw new ThrottledError
;
534 $ot = $this->oldTitle
;
535 $nt = $this->newTitle
;
537 # don't allow moving to pages with # in
538 if ( !$nt ||
$nt->hasFragment() ) {
539 $this->showForm( [ [ 'badtitletext' ] ] );
544 $services = MediaWikiServices
::getInstance();
546 # Show a warning if the target file exists on a shared repo
547 $repoGroup = $services->getRepoGroup();
548 if ( $nt->getNamespace() == NS_FILE
549 && !( $this->moveOverShared
&& $permissionManager->userHasRight( $user, 'reupload-shared' ) )
550 && !$repoGroup->getLocalRepo()->findFile( $nt )
551 && $repoGroup->findFile( $nt )
553 $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
558 # Delete to make way if requested
559 if ( $this->deleteAndMove
) {
560 $permErrors = $permissionManager->getPermissionErrors( 'delete', $user, $nt );
561 if ( count( $permErrors ) ) {
562 # Only show the first error
563 $this->showForm( $permErrors, true );
568 $page = WikiPage
::factory( $nt );
570 // Small safety margin to guard against concurrent edits
571 if ( $page->isBatchedDelete( 5 ) ) {
572 $this->showForm( [ [ 'movepage-delete-first' ] ] );
577 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
579 // Delete an associated image if there is
580 if ( $nt->getNamespace() == NS_FILE
) {
581 $file = $repoGroup->getLocalRepo()->newFile( $nt );
582 $file->load( File
::READ_LATEST
);
583 if ( $file->exists() ) {
584 $file->delete( $reason, false, $user );
588 $error = ''; // passed by ref
589 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
590 if ( !$deleteStatus->isGood() ) {
591 $this->showForm( $deleteStatus->getErrorsArray() );
597 $handler = ContentHandler
::getForTitle( $ot );
599 if ( !$handler->supportsRedirects() ) {
600 $createRedirect = false;
601 } elseif ( $permissionManager->userHasRight( $user, 'suppressredirect' ) ) {
602 $createRedirect = $this->leaveRedirect
;
604 $createRedirect = true;
607 # Do the actual move.
608 $mp = new MovePage( $ot, $nt );
610 # check whether the requested actions are permitted / possible
611 $userPermitted = $mp->checkPermissions( $user, $this->reason
)->isOK();
612 if ( $ot->isTalkPage() ||
$nt->isTalkPage() ) {
613 $this->moveTalk
= false;
615 if ( $this->moveSubpages
) {
616 $this->moveSubpages
= $permissionManager->userCan( 'move-subpages', $user, $ot );
619 $status = $mp->moveIfAllowed( $user, $this->reason
, $createRedirect );
620 if ( !$status->isOK() ) {
621 $this->showForm( $status->getErrorsArray(), !$userPermitted );
625 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects
) {
626 DoubleRedirectJob
::fixRedirects( 'move', $ot, $nt );
629 $out = $this->getOutput();
630 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
632 $linkRenderer = $this->getLinkRenderer();
633 $oldLink = $linkRenderer->makeLink(
636 [ 'id' => 'movepage-oldlink' ],
637 [ 'redirect' => 'no' ]
639 $newLink = $linkRenderer->makeKnownLink(
642 [ 'id' => 'movepage-newlink' ]
644 $oldText = $ot->getPrefixedText();
645 $newText = $nt->getPrefixedText();
647 if ( $ot->exists() ) {
648 // NOTE: we assume that if the old title exists, it's because it was re-created as
649 // a redirect to the new title. This is not safe, but what we did before was
650 // even worse: we just determined whether a redirect should have been created,
651 // and reported that it was created if it should have, without any checks.
652 // Also note that isRedirect() is unreliable because of T39209.
653 $msgName = 'movepage-moved-redirect';
655 $msgName = 'movepage-moved-noredirect';
658 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
659 $newLink )->params( $oldText, $newText )->parseAsBlock() );
660 $out->addWikiMsg( $msgName );
662 // Avoid PHP 7.1 warning from passing $this by reference
664 Hooks
::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
667 * Now we move extra pages we've been asked to move: subpages and talk
670 * First, make a list of id's. This might be marginally less efficient
671 * than a more direct method, but this is not a highly performance-cri-
672 * tical code path and readable code is more important here.
674 * If the target namespace doesn't allow subpages, moving with subpages
675 * would mean that you couldn't move them back in one operation, which
677 * @todo FIXME: A specific error message should be given in this case.
680 // @todo FIXME: Use Title::moveSubpages() here
681 $nsInfo = $services->getNamespaceInfo();
682 $dbr = wfGetDB( DB_MASTER
);
683 if ( $this->moveSubpages
&& (
684 $nsInfo->hasSubpages( $nt->getNamespace() ) ||
(
686 && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
690 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
691 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
693 $conds['page_namespace'] = [];
694 if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
695 $conds['page_namespace'][] = $ot->getNamespace();
697 if ( $this->moveTalk
&&
698 $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
700 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
702 } elseif ( $this->moveTalk
) {
704 'page_namespace' => $ot->getTalkPage()->getNamespace(),
705 'page_title' => $ot->getDBkey()
713 if ( !is_null( $conds ) ) {
714 $extraPages = TitleArray
::newFromResult(
715 $dbr->select( 'page',
716 [ 'page_id', 'page_namespace', 'page_title' ],
725 foreach ( $extraPages as $oldSubpage ) {
726 if ( $ot->equals( $oldSubpage ) ||
$nt->equals( $oldSubpage ) ) {
727 # Already did this one.
731 $newPageName = preg_replace(
732 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
733 StringUtils
::escapeRegexReplacement( $nt->getDBkey() ), # T23234
734 $oldSubpage->getDBkey()
737 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
738 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
739 $newNs = $nt->getNamespace();
740 } elseif ( $oldSubpage->isTalkPage() ) {
741 $newNs = $nt->getTalkPage()->getNamespace();
743 $newNs = $nt->getSubjectPage()->getNamespace();
746 # T16385: we need makeTitleSafe because the new page names may
747 # be longer than 255 characters.
748 $newSubpage = Title
::makeTitleSafe( $newNs, $newPageName );
749 if ( !$newSubpage ) {
750 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
751 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
752 ->params( Title
::makeName( $newNs, $newPageName ) )->escaped();
756 $mp = new MovePage( $oldSubpage, $newSubpage );
757 # This was copy-pasted from Renameuser, bleh.
758 if ( $newSubpage->exists() && !$mp->isValidMove()->isOK() ) {
759 $link = $linkRenderer->makeKnownLink( $newSubpage );
760 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
762 $status = $mp->moveIfAllowed( $user, $this->reason
, $createRedirect );
764 if ( $status->isOK() ) {
765 if ( $this->fixRedirects
) {
766 DoubleRedirectJob
::fixRedirects( 'move', $oldSubpage, $newSubpage );
768 $oldLink = $linkRenderer->makeLink(
772 [ 'redirect' => 'no' ]
775 $newLink = $linkRenderer->makeKnownLink( $newSubpage );
776 $extraOutput[] = $this->msg( 'movepage-page-moved' )
777 ->rawParams( $oldLink, $newLink )->escaped();
780 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
781 if ( $count >= $maximumMovedPages ) {
782 $extraOutput[] = $this->msg( 'movepage-max-pages' )
783 ->numParams( $maximumMovedPages )->escaped();
787 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
788 $newLink = $linkRenderer->makeLink( $newSubpage );
789 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
790 ->rawParams( $oldLink, $newLink )->escaped();
795 if ( $extraOutput !== [] ) {
796 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
799 # Deal with watches (we don't watch subpages)
800 WatchAction
::doWatchOrUnwatch( $this->watch
, $ot, $user );
801 WatchAction
::doWatchOrUnwatch( $this->watch
, $nt, $user );
804 function showLogFragment( $title ) {
805 $moveLogPage = new LogPage( 'move' );
806 $out = $this->getOutput();
807 $out->addHTML( Xml
::element( 'h2', null, $moveLogPage->getName()->text() ) );
808 LogEventsList
::showLogExtract( $out, 'move', $title );
812 * Show subpages of the page being moved. Section is not shown if both current
813 * namespace does not support subpages and no talk subpages were found.
815 * @param Title $title Page being moved.
817 function showSubpages( $title ) {
818 $nsHasSubpages = MediaWikiServices
::getInstance()->getNamespaceInfo()->
819 hasSubpages( $title->getNamespace() );
820 $subpages = $title->getSubpages();
821 $count = $subpages instanceof TitleArray ?
$subpages->count() : 0;
823 $titleIsTalk = $title->isTalkPage();
824 $subpagesTalk = $title->getTalkPage()->getSubpages();
825 $countTalk = $subpagesTalk instanceof TitleArray ?
$subpagesTalk->count() : 0;
826 $totalCount = $count +
$countTalk;
828 if ( !$nsHasSubpages && $countTalk == 0 ) {
832 $this->getOutput()->wrapWikiMsg(
834 [ 'movesubpage', ( $titleIsTalk ?
$count : $totalCount ) ]
837 if ( $nsHasSubpages ) {
838 $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
841 if ( !$titleIsTalk && $countTalk > 0 ) {
842 $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
846 function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
847 $out = $this->getOutput();
850 if ( $pagecount == 0 && $noSubpageMsg ) {
851 $out->addWikiMsg( 'movenosubpage' );
855 $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
856 $out->addHTML( "<ul>\n" );
858 $linkBatch = new LinkBatch( $subpages );
859 $linkBatch->setCaller( __METHOD__
);
860 $linkBatch->execute();
861 $linkRenderer = $this->getLinkRenderer();
863 foreach ( $subpages as $subpage ) {
864 $link = $linkRenderer->makeLink( $subpage );
865 $out->addHTML( "<li>$link</li>\n" );
867 $out->addHTML( "</ul>\n" );
871 * Return an array of subpages beginning with $search that this special page will accept.
873 * @param string $search Prefix to search for
874 * @param int $limit Maximum number of results to return (usually 10)
875 * @param int $offset Number of results to skip (usually 0)
876 * @return string[] Matching subpages
878 public function prefixSearchSubpages( $search, $limit, $offset ) {
879 return $this->prefixSearchString( $search, $limit, $offset );
882 protected function getGroupName() {