MediaWiki REL1_28
SpecialMovepage.php
Go to the documentation of this file.
1<?php
31 protected $oldTitle = null;
32
34 protected $newTitle;
35
37 protected $reason;
38
39 // Checks
40
42 protected $moveTalk;
43
45 protected $deleteAndMove;
46
48 protected $moveSubpages;
49
51 protected $fixRedirects;
52
54 protected $leaveRedirect;
55
57 protected $moveOverShared;
58
59 private $watch = false;
60
61 public function __construct() {
62 parent::__construct( 'Movepage' );
63 }
64
65 public function doesWrites() {
66 return true;
67 }
68
69 public function execute( $par ) {
71
72 $this->checkReadOnly();
73
74 $this->setHeaders();
75 $this->outputHeader();
76
77 $request = $this->getRequest();
78 $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
79
80 // Yes, the use of getVal() and getText() is wanted, see bug 20365
81
82 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
83 $this->oldTitle = Title::newFromText( $oldTitleText );
84
85 if ( !$this->oldTitle ) {
86 // Either oldTitle wasn't passed, or newFromText returned null
87 throw new ErrorPageError( 'notargettitle', 'notargettext' );
88 }
89 if ( !$this->oldTitle->exists() ) {
90 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
91 }
92
93 $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
94 $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
95 // Backwards compatibility for forms submitting here from other sources
96 // which is more common than it should be..
97 $newTitleText_bc = $request->getText( 'wpNewTitle' );
98 $this->newTitle = strlen( $newTitleText_bc ) > 0
99 ? Title::newFromText( $newTitleText_bc )
100 : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
101
102 $user = $this->getUser();
103
104 # Check rights
105 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
106 if ( count( $permErrors ) ) {
107 // Auto-block user's IP if the account was "hard" blocked
108 DeferredUpdates::addCallableUpdate( function() use ( $user ) {
109 $user->spreadAnyEditBlock();
110 } );
111 throw new PermissionsError( 'move', $permErrors );
112 }
113
114 $def = !$request->wasPosted();
115
116 $this->reason = $request->getText( 'wpReason' );
117 $this->moveTalk = $request->getBool( 'wpMovetalk', $def );
118 $this->fixRedirects = $request->getBool( 'wpFixRedirects', $def );
119 $this->leaveRedirect = $request->getBool( 'wpLeaveRedirect', $def );
120 $this->moveSubpages = $request->getBool( 'wpMovesubpages' );
121 $this->deleteAndMove = $request->getBool( 'wpDeleteAndMove' );
122 $this->moveOverShared = $request->getBool( 'wpMoveOverSharedFile' );
123 $this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
124
125 if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted()
126 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
127 ) {
128 $this->doSubmit();
129 } else {
130 $this->showForm( [] );
131 }
132 }
133
141 function showForm( $err ) {
142 $this->getSkin()->setRelevantTitle( $this->oldTitle );
143
144 $out = $this->getOutput();
145 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
146 $out->addModules( 'mediawiki.special.movePage' );
147 $out->addModuleStyles( 'mediawiki.special.movePage.styles' );
148 $this->addHelpLink( 'Help:Moving a page' );
149
150 $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
151 'movepagetext' :
152 'movepagetext-noredirectfixer'
153 );
154
155 if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
156 $out->wrapWikiMsg(
157 "<div class=\"warningbox mw-moveuserpage-warning\">\n$1\n</div>",
158 'moveuserpage-warning'
159 );
160 } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
161 $out->wrapWikiMsg(
162 "<div class=\"warningbox mw-movecategorypage-warning\">\n$1\n</div>",
163 'movecategorypage-warning'
164 );
165 }
166
167 $deleteAndMove = false;
168 $moveOverShared = false;
169
171
172 if ( !$newTitle ) {
173 # Show the current title as a default
174 # when the form is first opened.
176 } elseif ( !count( $err ) ) {
177 # If a title was supplied, probably from the move log revert
178 # link, check for validity. We can then show some diagnostic
179 # information and save a click.
180 $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
181 if ( is_array( $newerr ) ) {
182 $err = $newerr;
183 }
184 }
185
186 $user = $this->getUser();
187
188 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
189 && $newTitle->quickUserCan( 'delete', $user )
190 ) {
191 $out->wrapWikiMsg(
192 "<div class='warningbox'>\n$1\n</div>\n",
193 [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
194 );
195 $deleteAndMove = true;
196 $err = [];
197 }
198
199 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
200 && $user->isAllowed( 'reupload-shared' )
201 ) {
202 $out->wrapWikiMsg(
203 "<div class='warningbox'>\n$1\n</div>\n",
204 [
205 'move-over-sharedrepo',
207 ]
208 );
209 $moveOverShared = true;
210 $err = [];
211 }
212
213 $oldTalk = $this->oldTitle->getTalkPage();
214 $oldTitleSubpages = $this->oldTitle->hasSubpages();
215 $oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
216
217 $canMoveSubpage = ( $oldTitleSubpages || $oldTitleTalkSubpages ) &&
218 !count( $this->oldTitle->getUserPermissionsErrors( 'move-subpages', $user ) );
219
220 # We also want to be able to move assoc. subpage talk-pages even if base page
221 # has no associated talk page, so || with $oldTitleTalkSubpages.
222 $considerTalk = !$this->oldTitle->isTalkPage() &&
223 ( $oldTalk->exists()
224 || ( $oldTitleTalkSubpages && $canMoveSubpage ) );
225
227 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
228 $hasRedirects = $dbr->selectField( 'redirect', '1',
229 [
230 'rd_namespace' => $this->oldTitle->getNamespace(),
231 'rd_title' => $this->oldTitle->getDBkey(),
232 ], __METHOD__ );
233 } else {
234 $hasRedirects = false;
235 }
236
237 if ( count( $err ) ) {
238 $out->addHTML( "<div class='errorbox'>\n" );
239 $action_desc = $this->msg( 'action-move' )->plain();
240 $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
241
242 if ( count( $err ) == 1 ) {
243 $errMsg = $err[0];
244 $errMsgName = array_shift( $errMsg );
245
246 if ( $errMsgName == 'hookaborted' ) {
247 $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
248 } else {
249 $out->addWikiMsgArray( $errMsgName, $errMsg );
250 }
251 } else {
252 $errStr = [];
253
254 foreach ( $err as $errMsg ) {
255 if ( $errMsg[0] == 'hookaborted' ) {
256 $errStr[] = $errMsg[1];
257 } else {
258 $errMsgName = array_shift( $errMsg );
259 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
260 }
261 }
262
263 $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
264 }
265 $out->addHTML( "</div>\n" );
266 }
267
268 if ( $this->oldTitle->isProtected( 'move' ) ) {
269 # Is the title semi-protected?
270 if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
271 $noticeMsg = 'semiprotectedpagemovewarning';
272 $classes[] = 'mw-textarea-sprotected';
273 } else {
274 # Then it must be protected based on static groups (regular)
275 $noticeMsg = 'protectedpagemovewarning';
276 $classes[] = 'mw-textarea-protected';
277 }
278 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
279 $out->addWikiMsg( $noticeMsg );
281 $out,
282 'protect',
283 $this->oldTitle,
284 '',
285 [ 'lim' => 1 ]
286 );
287 $out->addHTML( "</div>\n" );
288 }
289
290 // Byte limit (not string length limit) for wpReason and wpNewTitleMain
291 // is enforced in the mediawiki.special.movePage module
292
293 $immovableNamespaces = [];
294 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
295 if ( !MWNamespace::isMovable( $nsId ) ) {
296 $immovableNamespaces[] = $nsId;
297 }
298 }
299
300 $handler = ContentHandler::getForTitle( $this->oldTitle );
301
302 $out->enableOOUI();
303 $fields = [];
304
305 $fields[] = new OOUI\FieldLayout(
306 new MediaWiki\Widget\ComplexTitleInputWidget( [
307 'id' => 'wpNewTitle',
308 'namespace' => [
309 'id' => 'wpNewTitleNs',
310 'name' => 'wpNewTitleNs',
311 'value' => $newTitle->getNamespace(),
312 'exclude' => $immovableNamespaces,
313 ],
314 'title' => [
315 'id' => 'wpNewTitleMain',
316 'name' => 'wpNewTitleMain',
317 'value' => $newTitle->getText(),
318 // Inappropriate, since we're expecting the user to input a non-existent page's title
319 'suggestions' => false,
320 ],
321 'infusable' => true,
322 ] ),
323 [
324 'label' => $this->msg( 'newtitle' )->text(),
325 'align' => 'top',
326 ]
327 );
328
329 $fields[] = new OOUI\FieldLayout(
330 new OOUI\TextInputWidget( [
331 'name' => 'wpReason',
332 'id' => 'wpReason',
333 'maxLength' => 200,
334 'infusable' => true,
335 'value' => $this->reason,
336 ] ),
337 [
338 'label' => $this->msg( 'movereason' )->text(),
339 'align' => 'top',
340 ]
341 );
342
343 if ( $considerTalk ) {
344 $fields[] = new OOUI\FieldLayout(
345 new OOUI\CheckboxInputWidget( [
346 'name' => 'wpMovetalk',
347 'id' => 'wpMovetalk',
348 'value' => '1',
349 'selected' => $this->moveTalk,
350 ] ),
351 [
352 'label' => $this->msg( 'movetalk' )->text(),
353 'help' => new OOUI\HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
354 'align' => 'inline',
355 'infusable' => true,
356 'id' => 'wpMovetalk-field',
357 ]
358 );
359 }
360
361 if ( $user->isAllowed( 'suppressredirect' ) ) {
362 if ( $handler->supportsRedirects() ) {
363 $isChecked = $this->leaveRedirect;
364 $isDisabled = false;
365 } else {
366 $isChecked = false;
367 $isDisabled = true;
368 }
369 $fields[] = new OOUI\FieldLayout(
370 new OOUI\CheckboxInputWidget( [
371 'name' => 'wpLeaveRedirect',
372 'id' => 'wpLeaveRedirect',
373 'value' => '1',
374 'selected' => $isChecked,
375 'disabled' => $isDisabled,
376 ] ),
377 [
378 'label' => $this->msg( 'move-leave-redirect' )->text(),
379 'align' => 'inline',
380 ]
381 );
382 }
383
384 if ( $hasRedirects ) {
385 $fields[] = new OOUI\FieldLayout(
386 new OOUI\CheckboxInputWidget( [
387 'name' => 'wpFixRedirects',
388 'id' => 'wpFixRedirects',
389 'value' => '1',
390 'selected' => $this->fixRedirects,
391 ] ),
392 [
393 'label' => $this->msg( 'fix-double-redirects' )->text(),
394 'align' => 'inline',
395 ]
396 );
397 }
398
399 if ( $canMoveSubpage ) {
400 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
401 $fields[] = new OOUI\FieldLayout(
402 new OOUI\CheckboxInputWidget( [
403 'name' => 'wpMovesubpages',
404 'id' => 'wpMovesubpages',
405 'value' => '1',
406 # Don't check the box if we only have talk subpages to
407 # move and we aren't moving the talk page.
408 'selected' => $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ),
409 ] ),
410 [
411 'label' => new OOUI\HtmlSnippet(
412 $this->msg(
413 ( $this->oldTitle->hasSubpages()
414 ? 'move-subpages'
415 : 'move-talk-subpages' )
416 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
417 ),
418 'align' => 'inline',
419 ]
420 );
421 }
422
423 # Don't allow watching if user is not logged in
424 if ( $user->isLoggedIn() ) {
425 $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
426 || $user->isWatched( $this->oldTitle ) );
427 $fields[] = new OOUI\FieldLayout(
428 new OOUI\CheckboxInputWidget( [
429 'name' => 'wpWatch',
430 'id' => 'watch', # ew
431 'value' => '1',
432 'selected' => $watchChecked,
433 ] ),
434 [
435 'label' => $this->msg( 'move-watch' )->text(),
436 'align' => 'inline',
437 ]
438 );
439 }
440
441 $hiddenFields = '';
442 if ( $moveOverShared ) {
443 $hiddenFields .= Html::hidden( 'wpMoveOverSharedFile', '1' );
444 }
445
446 if ( $deleteAndMove ) {
447 $fields[] = new OOUI\FieldLayout(
448 new OOUI\CheckboxInputWidget( [
449 'name' => 'wpDeleteAndMove',
450 'id' => 'wpDeleteAndMove',
451 'value' => '1',
452 ] ),
453 [
454 'label' => $this->msg( 'delete_and_move_confirm' )->text(),
455 'align' => 'inline',
456 ]
457 );
458 }
459
460 $fields[] = new OOUI\FieldLayout(
461 new OOUI\ButtonInputWidget( [
462 'name' => 'wpMove',
463 'value' => $this->msg( 'movepagebtn' )->text(),
464 'label' => $this->msg( 'movepagebtn' )->text(),
465 'flags' => [ 'primary', 'progressive' ],
466 'type' => 'submit',
467 ] ),
468 [
469 'align' => 'top',
470 ]
471 );
472
473 $fieldset = new OOUI\FieldsetLayout( [
474 'label' => $this->msg( 'move-page-legend' )->text(),
475 'id' => 'mw-movepage-table',
476 'items' => $fields,
477 ] );
478
479 $form = new OOUI\FormLayout( [
480 'method' => 'post',
481 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
482 'id' => 'movepage',
483 ] );
484 $form->appendContent(
485 $fieldset,
486 new OOUI\HtmlSnippet(
487 $hiddenFields .
488 Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
489 Html::hidden( 'wpEditToken', $user->getEditToken() )
490 )
491 );
492
493 $out->addHTML(
494 new OOUI\PanelLayout( [
495 'classes' => [ 'movepage-wrapper' ],
496 'expanded' => false,
497 'padded' => true,
498 'framed' => true,
499 'content' => $form,
500 ] )
501 );
502
503 $this->showLogFragment( $this->oldTitle );
504 $this->showSubpages( $this->oldTitle );
505 }
506
507 function doSubmit() {
508 $user = $this->getUser();
509
510 if ( $user->pingLimiter( 'move' ) ) {
511 throw new ThrottledError;
512 }
513
514 $ot = $this->oldTitle;
515 $nt = $this->newTitle;
516
517 # don't allow moving to pages with # in
518 if ( !$nt || $nt->hasFragment() ) {
519 $this->showForm( [ [ 'badtitletext' ] ] );
520
521 return;
522 }
523
524 # Show a warning if the target file exists on a shared repo
525 if ( $nt->getNamespace() == NS_FILE
526 && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
527 && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
528 && wfFindFile( $nt )
529 ) {
530 $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
531
532 return;
533 }
534
535 # Delete to make way if requested
536 if ( $this->deleteAndMove ) {
537 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
538 if ( count( $permErrors ) ) {
539 # Only show the first error
540 $this->showForm( $permErrors );
541
542 return;
543 }
544
545 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
546
547 // Delete an associated image if there is
548 if ( $nt->getNamespace() == NS_FILE ) {
549 $file = wfLocalFile( $nt );
550 $file->load( File::READ_LATEST );
551 if ( $file->exists() ) {
552 $file->delete( $reason, false, $user );
553 }
554 }
555
556 $error = ''; // passed by ref
557 $page = WikiPage::factory( $nt );
558 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
559 if ( !$deleteStatus->isGood() ) {
560 $this->showForm( $deleteStatus->getErrorsArray() );
561
562 return;
563 }
564 }
565
567
568 if ( !$handler->supportsRedirects() ) {
569 $createRedirect = false;
570 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
571 $createRedirect = $this->leaveRedirect;
572 } else {
573 $createRedirect = true;
574 }
575
576 # Do the actual move.
577 $mp = new MovePage( $ot, $nt );
578 $valid = $mp->isValidMove();
579 if ( !$valid->isOK() ) {
580 $this->showForm( $valid->getErrorsArray() );
581 return;
582 }
583
584 $permStatus = $mp->checkPermissions( $user, $this->reason );
585 if ( !$permStatus->isOK() ) {
586 $this->showForm( $permStatus->getErrorsArray() );
587 return;
588 }
589
590 $status = $mp->move( $user, $this->reason, $createRedirect );
591 if ( !$status->isOK() ) {
592 $this->showForm( $status->getErrorsArray() );
593 return;
594 }
595
596 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects ) {
597 DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
598 }
599
600 $out = $this->getOutput();
601 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
602
604 $oldLink = $linkRenderer->makeLink(
605 $ot,
606 null,
607 [ 'id' => 'movepage-oldlink' ],
608 [ 'redirect' => 'no' ]
609 );
610 $newLink = $linkRenderer->makeKnownLink(
611 $nt,
612 null,
613 [ 'id' => 'movepage-newlink' ]
614 );
615 $oldText = $ot->getPrefixedText();
616 $newText = $nt->getPrefixedText();
617
618 if ( $ot->exists() ) {
619 // NOTE: we assume that if the old title exists, it's because it was re-created as
620 // a redirect to the new title. This is not safe, but what we did before was
621 // even worse: we just determined whether a redirect should have been created,
622 // and reported that it was created if it should have, without any checks.
623 // Also note that isRedirect() is unreliable because of bug 37209.
624 $msgName = 'movepage-moved-redirect';
625 } else {
626 $msgName = 'movepage-moved-noredirect';
627 }
628
629 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
630 $newLink )->params( $oldText, $newText )->parseAsBlock() );
631 $out->addWikiMsg( $msgName );
632
633 // Avoid PHP 7.1 warning from passing $this by reference
634 $movePage = $this;
635 Hooks::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
636
637 # Now we move extra pages we've been asked to move: subpages and talk
638 # pages. First, if the old page or the new page is a talk page, we
639 # can't move any talk pages: cancel that.
640 if ( $ot->isTalkPage() || $nt->isTalkPage() ) {
641 $this->moveTalk = false;
642 }
643
644 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
645 $this->moveSubpages = false;
646 }
647
659 // @todo FIXME: Use Title::moveSubpages() here
661 if ( $this->moveSubpages && (
662 MWNamespace::hasSubpages( $nt->getNamespace() ) || (
663 $this->moveTalk
664 && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
665 )
666 ) ) {
667 $conds = [
668 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
669 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
670 ];
671 $conds['page_namespace'] = [];
672 if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
673 $conds['page_namespace'][] = $ot->getNamespace();
674 }
675 if ( $this->moveTalk &&
676 MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
677 ) {
678 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
679 }
680 } elseif ( $this->moveTalk ) {
681 $conds = [
682 'page_namespace' => $ot->getTalkPage()->getNamespace(),
683 'page_title' => $ot->getDBkey()
684 ];
685 } else {
686 # Skip the query
687 $conds = null;
688 }
689
690 $extraPages = [];
691 if ( !is_null( $conds ) ) {
692 $extraPages = TitleArray::newFromResult(
693 $dbr->select( 'page',
694 [ 'page_id', 'page_namespace', 'page_title' ],
695 $conds,
696 __METHOD__
697 )
698 );
699 }
700
701 $extraOutput = [];
702 $count = 1;
703 foreach ( $extraPages as $oldSubpage ) {
704 if ( $ot->equals( $oldSubpage ) || $nt->equals( $oldSubpage ) ) {
705 # Already did this one.
706 continue;
707 }
708
709 $newPageName = preg_replace(
710 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
711 StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
712 $oldSubpage->getDBkey()
713 );
714
715 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
716 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
717 $newNs = $nt->getNamespace();
718 } elseif ( $oldSubpage->isTalkPage() ) {
719 $newNs = $nt->getTalkPage()->getNamespace();
720 } else {
721 $newNs = $nt->getSubjectPage()->getNamespace();
722 }
723
724 # Bug 14385: we need makeTitleSafe because the new page names may
725 # be longer than 255 characters.
726 $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
727 if ( !$newSubpage ) {
728 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
729 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
730 ->params( Title::makeName( $newNs, $newPageName ) )->escaped();
731 continue;
732 }
733
734 # This was copy-pasted from Renameuser, bleh.
735 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
736 $link = $linkRenderer->makeKnownLink( $newSubpage );
737 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
738 } else {
739 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
740
741 if ( $success === true ) {
742 if ( $this->fixRedirects ) {
743 DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
744 }
745 $oldLink = $linkRenderer->makeLink(
746 $oldSubpage,
747 null,
748 [],
749 [ 'redirect' => 'no' ]
750 );
751
752 $newLink = $linkRenderer->makeKnownLink( $newSubpage );
753 $extraOutput[] = $this->msg( 'movepage-page-moved' )
754 ->rawParams( $oldLink, $newLink )->escaped();
755 ++$count;
756
757 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
758 if ( $count >= $maximumMovedPages ) {
759 $extraOutput[] = $this->msg( 'movepage-max-pages' )
760 ->numParams( $maximumMovedPages )->escaped();
761 break;
762 }
763 } else {
764 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
765 $newLink = $linkRenderer->makeLink( $newSubpage );
766 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
767 ->rawParams( $oldLink, $newLink )->escaped();
768 }
769 }
770 }
771
772 if ( $extraOutput !== [] ) {
773 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
774 }
775
776 # Deal with watches (we don't watch subpages)
777 WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user );
778 WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user );
779 }
780
781 function showLogFragment( $title ) {
782 $moveLogPage = new LogPage( 'move' );
783 $out = $this->getOutput();
784 $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
786 }
787
794 function showSubpages( $title ) {
795 $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() );
796 $subpages = $title->getSubpages();
797 $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
798
799 $titleIsTalk = $title->isTalkPage();
800 $subpagesTalk = $title->getTalkPage()->getSubpages();
801 $countTalk = $subpagesTalk instanceof TitleArray ? $subpagesTalk->count() : 0;
802 $totalCount = $count + $countTalk;
803
804 if ( !$nsHasSubpages && $countTalk == 0 ) {
805 return;
806 }
807
808 $this->getOutput()->wrapWikiMsg(
809 '== $1 ==',
810 [ 'movesubpage', ( $titleIsTalk ? $count : $totalCount ) ]
811 );
812
813 if ( $nsHasSubpages ) {
814 $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
815 }
816
817 if ( !$titleIsTalk && $countTalk > 0 ) {
818 $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
819 }
820 }
821
822 function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
823 $out = $this->getOutput();
824
825 # No subpages.
826 if ( $pagecount == 0 && $noSubpageMsg ) {
827 $out->addWikiMsg( 'movenosubpage' );
828 return;
829 }
830
831 $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
832 $out->addHTML( "<ul>\n" );
833
834 $linkBatch = new LinkBatch( $subpages );
835 $linkBatch->setCaller( __METHOD__ );
836 $linkBatch->execute();
838
839 foreach ( $subpages as $subpage ) {
840 $link = $linkRenderer->makeLink( $subpage );
841 $out->addHTML( "<li>$link</li>\n" );
842 }
843 $out->addHTML( "</ul>\n" );
844 }
845
854 public function prefixSearchSubpages( $search, $limit, $offset ) {
855 return $this->prefixSearchString( $search, $limit, $offset );
856 }
857
858 protected function getGroupName() {
859 return 'pagetools';
860 }
861}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfFindFile( $title, $options=[])
Find a file.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
static fixRedirects( $reason, $redirTitle, $destTitle=false)
Insert jobs into the job queue to fix redirects to the given title.
An error page which can definitely be safely rendered using the OutputPage.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:32
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class to simplify the use of log pages.
Definition LogPage.php:32
A special page that allows users to change page titles.
execute( $par)
Default execute method Checks user permissions.
showSubpages( $title)
Show subpages of the page being moved.
doesWrites()
Indicates whether this special page may perform database writes.
showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg=false)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
showLogFragment( $title)
string $reason
Text input.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
showForm( $err)
Show the form.
Handles the backend logic of moving a page from one title to another.
Definition MovePage.php:30
Show an error when a user tries to do something they do not have the necessary permissions for.
static singleton()
Get a RepoGroup instance.
Definition RepoGroup.php:59
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
msg()
Wrapper around wfMessage that sets the current context.
MediaWiki Linker LinkRenderer null $linkRenderer
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Show an error when the user hits a rate limit.
The TitleArray class only exists to provide the newFromResult method at pre- sent.
static newFromResult( $res)
Represents a title within MediaWiki.
Definition Title.php:36
getNamespace()
Get the namespace index, i.e.
Definition Title.php:921
isValidMoveOperation(&$nt, $auth=true, $reason='')
Check whether a given move operation would be valid.
Definition Title.php:3660
getText()
Get the text form (spaces not underscores) of the main part.
Definition Title.php:880
quickUserCan( $action, $user=null)
Can $user perform $action on this page? This skips potentially expensive cascading permission checks ...
Definition Title.php:1911
getPrefixedText()
Get the prefixed title with spaces.
Definition Title.php:1455
Shortcut to construct a special page which is unlisted by default.
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:115
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition Xml.php:39
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_USER
Definition Defines.php:58
const NS_FILE
Definition Defines.php:62
const NS_CATEGORY
Definition Defines.php:70
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2685
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition hooks.txt:1135
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:886
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2900
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
Definition hooks.txt:2543
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition hooks.txt:925
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
A helper class for throttling authentication attempts.
const DB_REPLICA
Definition defines.php:22
const DB_MASTER
Definition defines.php:23