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 $newTitle = $this->newTitle
;
176 # Show the current title as a default
177 # when the form is first opened.
178 $newTitle = $this->oldTitle
;
179 } elseif ( !count( $err ) ) {
180 # If a title was supplied, probably from the move log revert
181 # link, check for validity. We can then show some diagnostic
182 # information and save a click.
183 $newerr = $this->oldTitle
->isValidMoveOperation( $newTitle );
184 if ( is_array( $newerr ) ) {
189 $user = $this->getUser();
191 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
192 && $newTitle->quickUserCan( 'delete', $user )
195 "<div class='warningbox'>\n$1\n</div>\n",
196 [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
198 $deleteAndMove = true;
202 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
203 && $user->isAllowed( 'reupload-shared' )
206 "<div class='warningbox'>\n$1\n</div>\n",
208 'move-over-sharedrepo',
209 $newTitle->getPrefixedText()
212 $moveOverShared = true;
216 $oldTalk = $this->oldTitle
->getTalkPage();
217 $oldTitleSubpages = $this->oldTitle
->hasSubpages();
218 $oldTitleTalkSubpages = $this->oldTitle
->getTalkPage()->hasSubpages();
220 $canMoveSubpage = ( $oldTitleSubpages ||
$oldTitleTalkSubpages ) &&
221 !count( $this->oldTitle
->getUserPermissionsErrors( 'move-subpages', $user ) );
223 # We also want to be able to move assoc. subpage talk-pages even if base page
224 # has no associated talk page, so || with $oldTitleTalkSubpages.
225 $considerTalk = !$this->oldTitle
->isTalkPage() &&
227 ||
( $oldTitleTalkSubpages && $canMoveSubpage ) );
229 $dbr = wfGetDB( DB_REPLICA
);
230 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
231 $hasRedirects = $dbr->selectField( 'redirect', '1',
233 'rd_namespace' => $this->oldTitle
->getNamespace(),
234 'rd_title' => $this->oldTitle
->getDBkey(),
237 $hasRedirects = false;
240 if ( count( $err ) ) {
241 if ( $isPermError ) {
242 $action_desc = $this->msg( 'action-move' )->plain();
243 $errMsgHtml = $this->msg( 'permissionserrorstext-withaction',
244 count( $err ), $action_desc )->parseAsBlock();
246 $errMsgHtml = $this->msg( 'cannotmove', count( $err ) )->parseAsBlock();
249 if ( count( $err ) == 1 ) {
251 $errMsgName = array_shift( $errMsg );
253 if ( $errMsgName == 'hookaborted' ) {
254 $errMsgHtml .= "<p>{$errMsg[0]}</p>\n";
256 $errMsgHtml .= $this->msg( $errMsgName, $errMsg )->parseAsBlock();
261 foreach ( $err as $errMsg ) {
262 if ( $errMsg[0] == 'hookaborted' ) {
263 $errStr[] = $errMsg[1];
265 $errMsgName = array_shift( $errMsg );
266 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
270 $errMsgHtml .= '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n";
272 $out->addHTML( Html
::errorBox( $errMsgHtml ) );
275 if ( $this->oldTitle
->isProtected( 'move' ) ) {
276 # Is the title semi-protected?
277 if ( $this->oldTitle
->isSemiProtected( 'move' ) ) {
278 $noticeMsg = 'semiprotectedpagemovewarning';
279 $classes[] = 'mw-textarea-sprotected';
281 # Then it must be protected based on static groups (regular)
282 $noticeMsg = 'protectedpagemovewarning';
283 $classes[] = 'mw-textarea-protected';
285 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
286 $out->addWikiMsg( $noticeMsg );
287 LogEventsList
::showLogExtract(
294 $out->addHTML( "</div>\n" );
297 // Length limit for wpReason and wpNewTitleMain is enforced in the
298 // mediawiki.special.movePage module
300 $immovableNamespaces = [];
301 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
302 if ( !MediaWikiServices
::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
303 $immovableNamespaces[] = $nsId;
307 $handler = ContentHandler
::getForTitle( $this->oldTitle
);
312 $fields[] = new OOUI\
FieldLayout(
313 new MediaWiki\Widget\
ComplexTitleInputWidget( [
314 'id' => 'wpNewTitle',
316 'id' => 'wpNewTitleNs',
317 'name' => 'wpNewTitleNs',
318 'value' => $newTitle->getNamespace(),
319 'exclude' => $immovableNamespaces,
322 'id' => 'wpNewTitleMain',
323 'name' => 'wpNewTitleMain',
324 'value' => $newTitle->getText(),
325 // Inappropriate, since we're expecting the user to input a non-existent page's title
326 'suggestions' => false,
331 'label' => $this->msg( 'newtitle' )->text(),
336 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
337 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
338 // Unicode codepoints.
339 $fields[] = new OOUI\
FieldLayout(
340 new OOUI\
TextInputWidget( [
341 'name' => 'wpReason',
343 'maxLength' => CommentStore
::COMMENT_CHARACTER_LIMIT
,
345 'value' => $this->reason
,
348 'label' => $this->msg( 'movereason' )->text(),
353 if ( $considerTalk ) {
354 $fields[] = new OOUI\
FieldLayout(
355 new OOUI\
CheckboxInputWidget( [
356 'name' => 'wpMovetalk',
357 'id' => 'wpMovetalk',
359 'selected' => $this->moveTalk
,
362 'label' => $this->msg( 'movetalk' )->text(),
363 'help' => new OOUI\
HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
364 'helpInline' => true,
366 'id' => 'wpMovetalk-field',
371 if ( $user->isAllowed( 'suppressredirect' ) ) {
372 if ( $handler->supportsRedirects() ) {
373 $isChecked = $this->leaveRedirect
;
379 $fields[] = new OOUI\
FieldLayout(
380 new OOUI\
CheckboxInputWidget( [
381 'name' => 'wpLeaveRedirect',
382 'id' => 'wpLeaveRedirect',
384 'selected' => $isChecked,
385 'disabled' => $isDisabled,
388 'label' => $this->msg( 'move-leave-redirect' )->text(),
394 if ( $hasRedirects ) {
395 $fields[] = new OOUI\
FieldLayout(
396 new OOUI\
CheckboxInputWidget( [
397 'name' => 'wpFixRedirects',
398 'id' => 'wpFixRedirects',
400 'selected' => $this->fixRedirects
,
403 'label' => $this->msg( 'fix-double-redirects' )->text(),
409 if ( $canMoveSubpage ) {
410 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
411 $fields[] = new OOUI\
FieldLayout(
412 new OOUI\
CheckboxInputWidget( [
413 'name' => 'wpMovesubpages',
414 'id' => 'wpMovesubpages',
416 # Don't check the box if we only have talk subpages to
417 # move and we aren't moving the talk page.
418 'selected' => $this->moveSubpages
&& ( $this->oldTitle
->hasSubpages() ||
$this->moveTalk
),
421 'label' => new OOUI\
HtmlSnippet(
423 ( $this->oldTitle
->hasSubpages()
425 : 'move-talk-subpages' )
426 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
433 # Don't allow watching if user is not logged in
434 if ( $user->isLoggedIn() ) {
435 $watchChecked = $user->isLoggedIn() && ( $this->watch ||
$user->getBoolOption( 'watchmoves' )
436 ||
$user->isWatched( $this->oldTitle
) );
437 $fields[] = new OOUI\
FieldLayout(
438 new OOUI\
CheckboxInputWidget( [
440 'id' => 'watch', # ew
442 'selected' => $watchChecked,
445 'label' => $this->msg( 'move-watch' )->text(),
452 if ( $moveOverShared ) {
453 $hiddenFields .= Html
::hidden( 'wpMoveOverSharedFile', '1' );
456 if ( $deleteAndMove ) {
457 $fields[] = new OOUI\
FieldLayout(
458 new OOUI\
CheckboxInputWidget( [
459 'name' => 'wpDeleteAndMove',
460 'id' => 'wpDeleteAndMove',
464 'label' => $this->msg( 'delete_and_move_confirm' )->text(),
470 $fields[] = new OOUI\
FieldLayout(
471 new OOUI\
ButtonInputWidget( [
473 'value' => $this->msg( 'movepagebtn' )->text(),
474 'label' => $this->msg( 'movepagebtn' )->text(),
475 'flags' => [ 'primary', 'progressive' ],
483 $fieldset = new OOUI\
FieldsetLayout( [
484 'label' => $this->msg( 'move-page-legend' )->text(),
485 'id' => 'mw-movepage-table',
489 $form = new OOUI\
FormLayout( [
491 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
494 $form->appendContent(
496 new OOUI\
HtmlSnippet(
498 Html
::hidden( 'wpOldTitle', $this->oldTitle
->getPrefixedText() ) .
499 Html
::hidden( 'wpEditToken', $user->getEditToken() )
504 new OOUI\
PanelLayout( [
505 'classes' => [ 'movepage-wrapper' ],
513 $this->showLogFragment( $this->oldTitle
);
514 $this->showSubpages( $this->oldTitle
);
517 function doSubmit() {
518 $user = $this->getUser();
520 if ( $user->pingLimiter( 'move' ) ) {
521 throw new ThrottledError
;
524 $ot = $this->oldTitle
;
525 $nt = $this->newTitle
;
527 # don't allow moving to pages with # in
528 if ( !$nt ||
$nt->hasFragment() ) {
529 $this->showForm( [ [ 'badtitletext' ] ] );
534 # Show a warning if the target file exists on a shared repo
535 if ( $nt->getNamespace() == NS_FILE
536 && !( $this->moveOverShared
&& $user->isAllowed( 'reupload-shared' ) )
537 && !RepoGroup
::singleton()->getLocalRepo()->findFile( $nt )
540 $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
545 # Delete to make way if requested
546 if ( $this->deleteAndMove
) {
547 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
548 if ( count( $permErrors ) ) {
549 # Only show the first error
550 $this->showForm( $permErrors, true );
555 $page = WikiPage
::factory( $nt );
557 // Small safety margin to guard against concurrent edits
558 if ( $page->isBatchedDelete( 5 ) ) {
559 $this->showForm( [ [ 'movepage-delete-first' ] ] );
564 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
566 // Delete an associated image if there is
567 if ( $nt->getNamespace() == NS_FILE
) {
568 $file = wfLocalFile( $nt );
569 $file->load( File
::READ_LATEST
);
570 if ( $file->exists() ) {
571 $file->delete( $reason, false, $user );
575 $error = ''; // passed by ref
576 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
577 if ( !$deleteStatus->isGood() ) {
578 $this->showForm( $deleteStatus->getErrorsArray() );
584 $handler = ContentHandler
::getForTitle( $ot );
586 if ( !$handler->supportsRedirects() ) {
587 $createRedirect = false;
588 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
589 $createRedirect = $this->leaveRedirect
;
591 $createRedirect = true;
594 # Do the actual move.
595 $mp = new MovePage( $ot, $nt );
597 $userPermitted = $mp->checkPermissions( $user, $this->reason
)->isOK();
599 $status = $mp->moveIfAllowed( $user, $this->reason
, $createRedirect );
600 if ( !$status->isOK() ) {
601 $this->showForm( $status->getErrorsArray(), !$userPermitted );
605 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects
) {
606 DoubleRedirectJob
::fixRedirects( 'move', $ot, $nt );
609 $out = $this->getOutput();
610 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
612 $linkRenderer = $this->getLinkRenderer();
613 $oldLink = $linkRenderer->makeLink(
616 [ 'id' => 'movepage-oldlink' ],
617 [ 'redirect' => 'no' ]
619 $newLink = $linkRenderer->makeKnownLink(
622 [ 'id' => 'movepage-newlink' ]
624 $oldText = $ot->getPrefixedText();
625 $newText = $nt->getPrefixedText();
627 if ( $ot->exists() ) {
628 // NOTE: we assume that if the old title exists, it's because it was re-created as
629 // a redirect to the new title. This is not safe, but what we did before was
630 // even worse: we just determined whether a redirect should have been created,
631 // and reported that it was created if it should have, without any checks.
632 // Also note that isRedirect() is unreliable because of T39209.
633 $msgName = 'movepage-moved-redirect';
635 $msgName = 'movepage-moved-noredirect';
638 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
639 $newLink )->params( $oldText, $newText )->parseAsBlock() );
640 $out->addWikiMsg( $msgName );
642 // Avoid PHP 7.1 warning from passing $this by reference
644 Hooks
::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
646 # Now we move extra pages we've been asked to move: subpages and talk
647 # pages. First, if the old page or the new page is a talk page, we
648 # can't move any talk pages: cancel that.
649 if ( $ot->isTalkPage() ||
$nt->isTalkPage() ) {
650 $this->moveTalk
= false;
653 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
654 $this->moveSubpages
= false;
658 * Next make a list of id's. This might be marginally less efficient
659 * than a more direct method, but this is not a highly performance-cri-
660 * tical code path and readable code is more important here.
662 * If the target namespace doesn't allow subpages, moving with subpages
663 * would mean that you couldn't move them back in one operation, which
665 * @todo FIXME: A specific error message should be given in this case.
668 // @todo FIXME: Use Title::moveSubpages() here
669 $nsInfo = MediaWikiServices
::getInstance()->getNamespaceInfo();
670 $dbr = wfGetDB( DB_MASTER
);
671 if ( $this->moveSubpages
&& (
672 $nsInfo->hasSubpages( $nt->getNamespace() ) ||
(
674 && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
678 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
679 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
681 $conds['page_namespace'] = [];
682 if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
683 $conds['page_namespace'][] = $ot->getNamespace();
685 if ( $this->moveTalk
&&
686 $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
688 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
690 } elseif ( $this->moveTalk
) {
692 'page_namespace' => $ot->getTalkPage()->getNamespace(),
693 'page_title' => $ot->getDBkey()
701 if ( !is_null( $conds ) ) {
702 $extraPages = TitleArray
::newFromResult(
703 $dbr->select( 'page',
704 [ 'page_id', 'page_namespace', 'page_title' ],
713 foreach ( $extraPages as $oldSubpage ) {
714 if ( $ot->equals( $oldSubpage ) ||
$nt->equals( $oldSubpage ) ) {
715 # Already did this one.
719 $newPageName = preg_replace(
720 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
721 StringUtils
::escapeRegexReplacement( $nt->getDBkey() ), # T23234
722 $oldSubpage->getDBkey()
725 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
726 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
727 $newNs = $nt->getNamespace();
728 } elseif ( $oldSubpage->isTalkPage() ) {
729 $newNs = $nt->getTalkPage()->getNamespace();
731 $newNs = $nt->getSubjectPage()->getNamespace();
734 # T16385: we need makeTitleSafe because the new page names may
735 # be longer than 255 characters.
736 $newSubpage = Title
::makeTitleSafe( $newNs, $newPageName );
737 if ( !$newSubpage ) {
738 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
739 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
740 ->params( Title
::makeName( $newNs, $newPageName ) )->escaped();
744 # This was copy-pasted from Renameuser, bleh.
745 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
746 $link = $linkRenderer->makeKnownLink( $newSubpage );
747 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
749 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason
, $createRedirect );
751 if ( $success === true ) {
752 if ( $this->fixRedirects
) {
753 DoubleRedirectJob
::fixRedirects( 'move', $oldSubpage, $newSubpage );
755 $oldLink = $linkRenderer->makeLink(
759 [ 'redirect' => 'no' ]
762 $newLink = $linkRenderer->makeKnownLink( $newSubpage );
763 $extraOutput[] = $this->msg( 'movepage-page-moved' )
764 ->rawParams( $oldLink, $newLink )->escaped();
767 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
768 if ( $count >= $maximumMovedPages ) {
769 $extraOutput[] = $this->msg( 'movepage-max-pages' )
770 ->numParams( $maximumMovedPages )->escaped();
774 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
775 $newLink = $linkRenderer->makeLink( $newSubpage );
776 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
777 ->rawParams( $oldLink, $newLink )->escaped();
782 if ( $extraOutput !== [] ) {
783 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
786 # Deal with watches (we don't watch subpages)
787 WatchAction
::doWatchOrUnwatch( $this->watch
, $ot, $user );
788 WatchAction
::doWatchOrUnwatch( $this->watch
, $nt, $user );
791 function showLogFragment( $title ) {
792 $moveLogPage = new LogPage( 'move' );
793 $out = $this->getOutput();
794 $out->addHTML( Xml
::element( 'h2', null, $moveLogPage->getName()->text() ) );
795 LogEventsList
::showLogExtract( $out, 'move', $title );
799 * Show subpages of the page being moved. Section is not shown if both current
800 * namespace does not support subpages and no talk subpages were found.
802 * @param Title $title Page being moved.
804 function showSubpages( $title ) {
805 $nsHasSubpages = MediaWikiServices
::getInstance()->getNamespaceInfo()->
806 hasSubpages( $title->getNamespace() );
807 $subpages = $title->getSubpages();
808 $count = $subpages instanceof TitleArray ?
$subpages->count() : 0;
810 $titleIsTalk = $title->isTalkPage();
811 $subpagesTalk = $title->getTalkPage()->getSubpages();
812 $countTalk = $subpagesTalk instanceof TitleArray ?
$subpagesTalk->count() : 0;
813 $totalCount = $count +
$countTalk;
815 if ( !$nsHasSubpages && $countTalk == 0 ) {
819 $this->getOutput()->wrapWikiMsg(
821 [ 'movesubpage', ( $titleIsTalk ?
$count : $totalCount ) ]
824 if ( $nsHasSubpages ) {
825 $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
828 if ( !$titleIsTalk && $countTalk > 0 ) {
829 $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
833 function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
834 $out = $this->getOutput();
837 if ( $pagecount == 0 && $noSubpageMsg ) {
838 $out->addWikiMsg( 'movenosubpage' );
842 $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
843 $out->addHTML( "<ul>\n" );
845 $linkBatch = new LinkBatch( $subpages );
846 $linkBatch->setCaller( __METHOD__
);
847 $linkBatch->execute();
848 $linkRenderer = $this->getLinkRenderer();
850 foreach ( $subpages as $subpage ) {
851 $link = $linkRenderer->makeLink( $subpage );
852 $out->addHTML( "<li>$link</li>\n" );
854 $out->addHTML( "</ul>\n" );
858 * Return an array of subpages beginning with $search that this special page will accept.
860 * @param string $search Prefix to search for
861 * @param int $limit Maximum number of results to return (usually 10)
862 * @param int $offset Number of results to skip (usually 0)
863 * @return string[] Matching subpages
865 public function prefixSearchSubpages( $search, $limit, $offset ) {
866 return $this->prefixSearchString( $search, $limit, $offset );
869 protected function getGroupName() {