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.special.movePage' );
151 $this->addHelpLink( 'Help:Moving a page' );
153 $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
155 'movepagetext-noredirectfixer'
158 if ( $this->oldTitle
->getNamespace() == NS_USER
&& !$this->oldTitle
->isSubpage() ) {
160 "<div class=\"warningbox mw-moveuserpage-warning\">\n$1\n</div>",
161 'moveuserpage-warning'
163 } elseif ( $this->oldTitle
->getNamespace() == NS_CATEGORY
) {
165 "<div class=\"warningbox mw-movecategorypage-warning\">\n$1\n</div>",
166 'movecategorypage-warning'
170 $deleteAndMove = false;
171 $moveOverShared = false;
173 $user = $this->getUser();
175 $newTitle = $this->newTitle
;
178 # Show the current title as a default
179 # when the form is first opened.
180 $newTitle = $this->oldTitle
;
181 } elseif ( !count( $err ) ) {
182 # If a title was supplied, probably from the move log revert
183 # link, check for validity. We can then show some diagnostic
184 # information and save a click.
185 $mp = new MovePage( $this->oldTitle
, $newTitle );
186 $status = $mp->isValidMove();
187 $status->merge( $mp->checkPermissions( $user, null ) );
188 if ( $status->getErrors() ) {
189 $err = $status->getErrorsArray();
193 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
194 && $newTitle->quickUserCan( 'delete', $user )
197 "<div class='warningbox'>\n$1\n</div>\n",
198 [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
200 $deleteAndMove = true;
204 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
205 && $user->isAllowed( 'reupload-shared' )
208 "<div class='warningbox'>\n$1\n</div>\n",
210 'move-over-sharedrepo',
211 $newTitle->getPrefixedText()
214 $moveOverShared = true;
218 $oldTalk = $this->oldTitle
->getTalkPage();
219 $oldTitleSubpages = $this->oldTitle
->hasSubpages();
220 $oldTitleTalkSubpages = $this->oldTitle
->getTalkPage()->hasSubpages();
222 $canMoveSubpage = ( $oldTitleSubpages ||
$oldTitleTalkSubpages ) &&
223 !count( $this->oldTitle
->getUserPermissionsErrors( 'move-subpages', $user ) );
225 # We also want to be able to move assoc. subpage talk-pages even if base page
226 # has no associated talk page, so || with $oldTitleTalkSubpages.
227 $considerTalk = !$this->oldTitle
->isTalkPage() &&
229 ||
( $oldTitleTalkSubpages && $canMoveSubpage ) );
231 $dbr = wfGetDB( DB_REPLICA
);
232 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
233 $hasRedirects = $dbr->selectField( 'redirect', '1',
235 'rd_namespace' => $this->oldTitle
->getNamespace(),
236 'rd_title' => $this->oldTitle
->getDBkey(),
239 $hasRedirects = false;
242 if ( count( $err ) ) {
243 if ( $isPermError ) {
244 $action_desc = $this->msg( 'action-move' )->plain();
245 $errMsgHtml = $this->msg( 'permissionserrorstext-withaction',
246 count( $err ), $action_desc )->parseAsBlock();
248 $errMsgHtml = $this->msg( 'cannotmove', count( $err ) )->parseAsBlock();
251 if ( count( $err ) == 1 ) {
253 $errMsgName = array_shift( $errMsg );
255 if ( $errMsgName == 'hookaborted' ) {
256 $errMsgHtml .= "<p>{$errMsg[0]}</p>\n";
258 $errMsgHtml .= $this->msg( $errMsgName, $errMsg )->parseAsBlock();
263 foreach ( $err as $errMsg ) {
264 if ( $errMsg[0] == 'hookaborted' ) {
265 $errStr[] = $errMsg[1];
267 $errMsgName = array_shift( $errMsg );
268 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
272 $errMsgHtml .= '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n";
274 $out->addHTML( Html
::errorBox( $errMsgHtml ) );
277 if ( $this->oldTitle
->isProtected( 'move' ) ) {
278 # Is the title semi-protected?
279 if ( $this->oldTitle
->isSemiProtected( 'move' ) ) {
280 $noticeMsg = 'semiprotectedpagemovewarning';
281 $classes[] = 'mw-textarea-sprotected';
283 # Then it must be protected based on static groups (regular)
284 $noticeMsg = 'protectedpagemovewarning';
285 $classes[] = 'mw-textarea-protected';
287 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
288 $out->addWikiMsg( $noticeMsg );
289 LogEventsList
::showLogExtract(
296 $out->addHTML( "</div>\n" );
299 // Length limit for wpReason and wpNewTitleMain is enforced in the
300 // mediawiki.special.movePage module
302 $immovableNamespaces = [];
303 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
304 if ( !MediaWikiServices
::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
305 $immovableNamespaces[] = $nsId;
309 $handler = ContentHandler
::getForTitle( $this->oldTitle
);
314 $fields[] = new OOUI\
FieldLayout(
315 new MediaWiki\Widget\
ComplexTitleInputWidget( [
316 'id' => 'wpNewTitle',
318 'id' => 'wpNewTitleNs',
319 'name' => 'wpNewTitleNs',
320 'value' => $newTitle->getNamespace(),
321 'exclude' => $immovableNamespaces,
324 'id' => 'wpNewTitleMain',
325 'name' => 'wpNewTitleMain',
326 'value' => $newTitle->getText(),
327 // Inappropriate, since we're expecting the user to input a non-existent page's title
328 'suggestions' => false,
333 'label' => $this->msg( 'newtitle' )->text(),
338 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
339 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
340 // Unicode codepoints.
341 $fields[] = new OOUI\
FieldLayout(
342 new OOUI\
TextInputWidget( [
343 'name' => 'wpReason',
345 'maxLength' => CommentStore
::COMMENT_CHARACTER_LIMIT
,
347 'value' => $this->reason
,
350 'label' => $this->msg( 'movereason' )->text(),
355 if ( $considerTalk ) {
356 $fields[] = new OOUI\
FieldLayout(
357 new OOUI\
CheckboxInputWidget( [
358 'name' => 'wpMovetalk',
359 'id' => 'wpMovetalk',
361 'selected' => $this->moveTalk
,
364 'label' => $this->msg( 'movetalk' )->text(),
365 'help' => new OOUI\
HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
366 'helpInline' => true,
368 'id' => 'wpMovetalk-field',
373 if ( $user->isAllowed( 'suppressredirect' ) ) {
374 if ( $handler->supportsRedirects() ) {
375 $isChecked = $this->leaveRedirect
;
381 $fields[] = new OOUI\
FieldLayout(
382 new OOUI\
CheckboxInputWidget( [
383 'name' => 'wpLeaveRedirect',
384 'id' => 'wpLeaveRedirect',
386 'selected' => $isChecked,
387 'disabled' => $isDisabled,
390 'label' => $this->msg( 'move-leave-redirect' )->text(),
396 if ( $hasRedirects ) {
397 $fields[] = new OOUI\
FieldLayout(
398 new OOUI\
CheckboxInputWidget( [
399 'name' => 'wpFixRedirects',
400 'id' => 'wpFixRedirects',
402 'selected' => $this->fixRedirects
,
405 'label' => $this->msg( 'fix-double-redirects' )->text(),
411 if ( $canMoveSubpage ) {
412 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
413 $fields[] = new OOUI\
FieldLayout(
414 new OOUI\
CheckboxInputWidget( [
415 'name' => 'wpMovesubpages',
416 'id' => 'wpMovesubpages',
418 # Don't check the box if we only have talk subpages to
419 # move and we aren't moving the talk page.
420 'selected' => $this->moveSubpages
&& ( $this->oldTitle
->hasSubpages() ||
$this->moveTalk
),
423 'label' => new OOUI\
HtmlSnippet(
425 ( $this->oldTitle
->hasSubpages()
427 : 'move-talk-subpages' )
428 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
435 # Don't allow watching if user is not logged in
436 if ( $user->isLoggedIn() ) {
437 $watchChecked = $user->isLoggedIn() && ( $this->watch ||
$user->getBoolOption( 'watchmoves' )
438 ||
$user->isWatched( $this->oldTitle
) );
439 $fields[] = new OOUI\
FieldLayout(
440 new OOUI\
CheckboxInputWidget( [
442 'id' => 'watch', # ew
444 'selected' => $watchChecked,
447 'label' => $this->msg( 'move-watch' )->text(),
454 if ( $moveOverShared ) {
455 $hiddenFields .= Html
::hidden( 'wpMoveOverSharedFile', '1' );
458 if ( $deleteAndMove ) {
459 $fields[] = new OOUI\
FieldLayout(
460 new OOUI\
CheckboxInputWidget( [
461 'name' => 'wpDeleteAndMove',
462 'id' => 'wpDeleteAndMove',
466 'label' => $this->msg( 'delete_and_move_confirm' )->text(),
472 $fields[] = new OOUI\
FieldLayout(
473 new OOUI\
ButtonInputWidget( [
475 'value' => $this->msg( 'movepagebtn' )->text(),
476 'label' => $this->msg( 'movepagebtn' )->text(),
477 'flags' => [ 'primary', 'progressive' ],
485 $fieldset = new OOUI\
FieldsetLayout( [
486 'label' => $this->msg( 'move-page-legend' )->text(),
487 'id' => 'mw-movepage-table',
491 $form = new OOUI\
FormLayout( [
493 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
496 $form->appendContent(
498 new OOUI\
HtmlSnippet(
500 Html
::hidden( 'wpOldTitle', $this->oldTitle
->getPrefixedText() ) .
501 Html
::hidden( 'wpEditToken', $user->getEditToken() )
506 new OOUI\
PanelLayout( [
507 'classes' => [ 'movepage-wrapper' ],
515 $this->showLogFragment( $this->oldTitle
);
516 $this->showSubpages( $this->oldTitle
);
519 function doSubmit() {
520 $user = $this->getUser();
522 if ( $user->pingLimiter( 'move' ) ) {
523 throw new ThrottledError
;
526 $ot = $this->oldTitle
;
527 $nt = $this->newTitle
;
529 # don't allow moving to pages with # in
530 if ( !$nt ||
$nt->hasFragment() ) {
531 $this->showForm( [ [ 'badtitletext' ] ] );
536 # Show a warning if the target file exists on a shared repo
537 if ( $nt->getNamespace() == NS_FILE
538 && !( $this->moveOverShared
&& $user->isAllowed( 'reupload-shared' ) )
539 && !RepoGroup
::singleton()->getLocalRepo()->findFile( $nt )
542 $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
547 # Delete to make way if requested
548 if ( $this->deleteAndMove
) {
549 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
550 if ( count( $permErrors ) ) {
551 # Only show the first error
552 $this->showForm( $permErrors, true );
557 $page = WikiPage
::factory( $nt );
559 // Small safety margin to guard against concurrent edits
560 if ( $page->isBatchedDelete( 5 ) ) {
561 $this->showForm( [ [ 'movepage-delete-first' ] ] );
566 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
568 // Delete an associated image if there is
569 if ( $nt->getNamespace() == NS_FILE
) {
570 $file = wfLocalFile( $nt );
571 $file->load( File
::READ_LATEST
);
572 if ( $file->exists() ) {
573 $file->delete( $reason, false, $user );
577 $error = ''; // passed by ref
578 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
579 if ( !$deleteStatus->isGood() ) {
580 $this->showForm( $deleteStatus->getErrorsArray() );
586 $handler = ContentHandler
::getForTitle( $ot );
588 if ( !$handler->supportsRedirects() ) {
589 $createRedirect = false;
590 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
591 $createRedirect = $this->leaveRedirect
;
593 $createRedirect = true;
596 # Do the actual move.
597 $mp = new MovePage( $ot, $nt );
599 $userPermitted = $mp->checkPermissions( $user, $this->reason
)->isOK();
601 $status = $mp->moveIfAllowed( $user, $this->reason
, $createRedirect );
602 if ( !$status->isOK() ) {
603 $this->showForm( $status->getErrorsArray(), !$userPermitted );
607 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects
) {
608 DoubleRedirectJob
::fixRedirects( 'move', $ot, $nt );
611 $out = $this->getOutput();
612 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
614 $linkRenderer = $this->getLinkRenderer();
615 $oldLink = $linkRenderer->makeLink(
618 [ 'id' => 'movepage-oldlink' ],
619 [ 'redirect' => 'no' ]
621 $newLink = $linkRenderer->makeKnownLink(
624 [ 'id' => 'movepage-newlink' ]
626 $oldText = $ot->getPrefixedText();
627 $newText = $nt->getPrefixedText();
629 if ( $ot->exists() ) {
630 // NOTE: we assume that if the old title exists, it's because it was re-created as
631 // a redirect to the new title. This is not safe, but what we did before was
632 // even worse: we just determined whether a redirect should have been created,
633 // and reported that it was created if it should have, without any checks.
634 // Also note that isRedirect() is unreliable because of T39209.
635 $msgName = 'movepage-moved-redirect';
637 $msgName = 'movepage-moved-noredirect';
640 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
641 $newLink )->params( $oldText, $newText )->parseAsBlock() );
642 $out->addWikiMsg( $msgName );
644 // Avoid PHP 7.1 warning from passing $this by reference
646 Hooks
::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
648 # Now we move extra pages we've been asked to move: subpages and talk
649 # pages. First, if the old page or the new page is a talk page, we
650 # can't move any talk pages: cancel that.
651 if ( $ot->isTalkPage() ||
$nt->isTalkPage() ) {
652 $this->moveTalk
= false;
655 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
656 $this->moveSubpages
= false;
660 * Next make a list of id's. This might be marginally less efficient
661 * than a more direct method, but this is not a highly performance-cri-
662 * tical code path and readable code is more important here.
664 * If the target namespace doesn't allow subpages, moving with subpages
665 * would mean that you couldn't move them back in one operation, which
667 * @todo FIXME: A specific error message should be given in this case.
670 // @todo FIXME: Use Title::moveSubpages() here
671 $nsInfo = MediaWikiServices
::getInstance()->getNamespaceInfo();
672 $dbr = wfGetDB( DB_MASTER
);
673 if ( $this->moveSubpages
&& (
674 $nsInfo->hasSubpages( $nt->getNamespace() ) ||
(
676 && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
680 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
681 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
683 $conds['page_namespace'] = [];
684 if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
685 $conds['page_namespace'][] = $ot->getNamespace();
687 if ( $this->moveTalk
&&
688 $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
690 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
692 } elseif ( $this->moveTalk
) {
694 'page_namespace' => $ot->getTalkPage()->getNamespace(),
695 'page_title' => $ot->getDBkey()
703 if ( !is_null( $conds ) ) {
704 $extraPages = TitleArray
::newFromResult(
705 $dbr->select( 'page',
706 [ 'page_id', 'page_namespace', 'page_title' ],
715 foreach ( $extraPages as $oldSubpage ) {
716 if ( $ot->equals( $oldSubpage ) ||
$nt->equals( $oldSubpage ) ) {
717 # Already did this one.
721 $newPageName = preg_replace(
722 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
723 StringUtils
::escapeRegexReplacement( $nt->getDBkey() ), # T23234
724 $oldSubpage->getDBkey()
727 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
728 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
729 $newNs = $nt->getNamespace();
730 } elseif ( $oldSubpage->isTalkPage() ) {
731 $newNs = $nt->getTalkPage()->getNamespace();
733 $newNs = $nt->getSubjectPage()->getNamespace();
736 # T16385: we need makeTitleSafe because the new page names may
737 # be longer than 255 characters.
738 $newSubpage = Title
::makeTitleSafe( $newNs, $newPageName );
739 if ( !$newSubpage ) {
740 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
741 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
742 ->params( Title
::makeName( $newNs, $newPageName ) )->escaped();
746 $mp = new MovePage( $oldSubpage, $newSubpage );
747 # This was copy-pasted from Renameuser, bleh.
748 if ( $newSubpage->exists() && !$mp->isValidMove()->isOk() ) {
749 $link = $linkRenderer->makeKnownLink( $newSubpage );
750 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
752 $status = $mp->moveIfAllowed( $user, $this->reason
, $createRedirect );
754 if ( $status->isOK() ) {
755 if ( $this->fixRedirects
) {
756 DoubleRedirectJob
::fixRedirects( 'move', $oldSubpage, $newSubpage );
758 $oldLink = $linkRenderer->makeLink(
762 [ 'redirect' => 'no' ]
765 $newLink = $linkRenderer->makeKnownLink( $newSubpage );
766 $extraOutput[] = $this->msg( 'movepage-page-moved' )
767 ->rawParams( $oldLink, $newLink )->escaped();
770 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
771 if ( $count >= $maximumMovedPages ) {
772 $extraOutput[] = $this->msg( 'movepage-max-pages' )
773 ->numParams( $maximumMovedPages )->escaped();
777 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
778 $newLink = $linkRenderer->makeLink( $newSubpage );
779 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
780 ->rawParams( $oldLink, $newLink )->escaped();
785 if ( $extraOutput !== [] ) {
786 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
789 # Deal with watches (we don't watch subpages)
790 WatchAction
::doWatchOrUnwatch( $this->watch
, $ot, $user );
791 WatchAction
::doWatchOrUnwatch( $this->watch
, $nt, $user );
794 function showLogFragment( $title ) {
795 $moveLogPage = new LogPage( 'move' );
796 $out = $this->getOutput();
797 $out->addHTML( Xml
::element( 'h2', null, $moveLogPage->getName()->text() ) );
798 LogEventsList
::showLogExtract( $out, 'move', $title );
802 * Show subpages of the page being moved. Section is not shown if both current
803 * namespace does not support subpages and no talk subpages were found.
805 * @param Title $title Page being moved.
807 function showSubpages( $title ) {
808 $nsHasSubpages = MediaWikiServices
::getInstance()->getNamespaceInfo()->
809 hasSubpages( $title->getNamespace() );
810 $subpages = $title->getSubpages();
811 $count = $subpages instanceof TitleArray ?
$subpages->count() : 0;
813 $titleIsTalk = $title->isTalkPage();
814 $subpagesTalk = $title->getTalkPage()->getSubpages();
815 $countTalk = $subpagesTalk instanceof TitleArray ?
$subpagesTalk->count() : 0;
816 $totalCount = $count +
$countTalk;
818 if ( !$nsHasSubpages && $countTalk == 0 ) {
822 $this->getOutput()->wrapWikiMsg(
824 [ 'movesubpage', ( $titleIsTalk ?
$count : $totalCount ) ]
827 if ( $nsHasSubpages ) {
828 $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
831 if ( !$titleIsTalk && $countTalk > 0 ) {
832 $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
836 function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
837 $out = $this->getOutput();
840 if ( $pagecount == 0 && $noSubpageMsg ) {
841 $out->addWikiMsg( 'movenosubpage' );
845 $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
846 $out->addHTML( "<ul>\n" );
848 $linkBatch = new LinkBatch( $subpages );
849 $linkBatch->setCaller( __METHOD__
);
850 $linkBatch->execute();
851 $linkRenderer = $this->getLinkRenderer();
853 foreach ( $subpages as $subpage ) {
854 $link = $linkRenderer->makeLink( $subpage );
855 $out->addHTML( "<li>$link</li>\n" );
857 $out->addHTML( "</ul>\n" );
861 * Return an array of subpages beginning with $search that this special page will accept.
863 * @param string $search Prefix to search for
864 * @param int $limit Maximum number of results to return (usually 10)
865 * @param int $offset Number of results to skip (usually 0)
866 * @return string[] Matching subpages
868 public function prefixSearchSubpages( $search, $limit, $offset ) {
869 return $this->prefixSearchString( $search, $limit, $offset );
872 protected function getGroupName() {