MediaWiki  1.27.2
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
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 ) {
143 
144  $this->getSkin()->setRelevantTitle( $this->oldTitle );
145 
146  $out = $this->getOutput();
147  $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
148  $out->addModules( 'mediawiki.special.movePage' );
149  $out->addModuleStyles( 'mediawiki.special.movePage.styles' );
150  $this->addHelpLink( 'Help:Moving a page' );
151 
152  $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
153  'movepagetext' :
154  'movepagetext-noredirectfixer'
155  );
156 
157  if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
158  $out->wrapWikiMsg(
159  "<div class=\"warningbox mw-moveuserpage-warning\">\n$1\n</div>",
160  'moveuserpage-warning'
161  );
162  } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
163  $out->wrapWikiMsg(
164  "<div class=\"warningbox mw-movecategorypage-warning\">\n$1\n</div>",
165  'movecategorypage-warning'
166  );
167  }
168 
169  $deleteAndMove = false;
170  $moveOverShared = false;
171 
173 
174  if ( !$newTitle ) {
175  # Show the current title as a default
176  # when the form is first opened.
178  } elseif ( !count( $err ) ) {
179  # If a title was supplied, probably from the move log revert
180  # link, check for validity. We can then show some diagnostic
181  # information and save a click.
182  $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
183  if ( is_array( $newerr ) ) {
184  $err = $newerr;
185  }
186  }
187 
188  $user = $this->getUser();
189 
190  if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
191  && $newTitle->quickUserCan( 'delete', $user )
192  ) {
193  $out->wrapWikiMsg(
194  "<div class='warningbox'>\n$1\n</div>\n",
195  [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
196  );
197  $deleteAndMove = true;
198  $err = [];
199  }
200 
201  if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
202  && $user->isAllowed( 'reupload-shared' )
203  ) {
204  $out->wrapWikiMsg(
205  "<div class='warningbox'>\n$1\n</div>\n",
206  [
207  'move-over-sharedrepo',
209  ]
210  );
211  $moveOverShared = true;
212  $err = [];
213  }
214 
215  $oldTalk = $this->oldTitle->getTalkPage();
216  $oldTitleSubpages = $this->oldTitle->hasSubpages();
217  $oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
218 
219  $canMoveSubpage = ( $oldTitleSubpages || $oldTitleTalkSubpages ) &&
220  !count( $this->oldTitle->getUserPermissionsErrors( 'move-subpages', $user ) );
221 
222  # We also want to be able to move assoc. subpage talk-pages even if base page
223  # has no associated talk page, so || with $oldTitleTalkSubpages.
224  $considerTalk = !$this->oldTitle->isTalkPage() &&
225  ( $oldTalk->exists()
226  || ( $oldTitleTalkSubpages && $canMoveSubpage ) );
227 
228  $dbr = wfGetDB( DB_SLAVE );
229  if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
230  $hasRedirects = $dbr->selectField( 'redirect', '1',
231  [
232  'rd_namespace' => $this->oldTitle->getNamespace(),
233  'rd_title' => $this->oldTitle->getDBkey(),
234  ], __METHOD__ );
235  } else {
236  $hasRedirects = false;
237  }
238 
239  if ( count( $err ) ) {
240  $out->addHTML( "<div class='errorbox'>\n" );
241  $action_desc = $this->msg( 'action-move' )->plain();
242  $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
243 
244  if ( count( $err ) == 1 ) {
245  $errMsg = $err[0];
246  $errMsgName = array_shift( $errMsg );
247 
248  if ( $errMsgName == 'hookaborted' ) {
249  $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
250  } else {
251  $out->addWikiMsgArray( $errMsgName, $errMsg );
252  }
253  } else {
254  $errStr = [];
255 
256  foreach ( $err as $errMsg ) {
257  if ( $errMsg[0] == 'hookaborted' ) {
258  $errStr[] = $errMsg[1];
259  } else {
260  $errMsgName = array_shift( $errMsg );
261  $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
262  }
263  }
264 
265  $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
266  }
267  $out->addHTML( "</div>\n" );
268  }
269 
270  if ( $this->oldTitle->isProtected( 'move' ) ) {
271  # Is the title semi-protected?
272  if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
273  $noticeMsg = 'semiprotectedpagemovewarning';
274  $classes[] = 'mw-textarea-sprotected';
275  } else {
276  # Then it must be protected based on static groups (regular)
277  $noticeMsg = 'protectedpagemovewarning';
278  $classes[] = 'mw-textarea-protected';
279  }
280  $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
281  $out->addWikiMsg( $noticeMsg );
283  $out,
284  'protect',
285  $this->oldTitle,
286  '',
287  [ 'lim' => 1 ]
288  );
289  $out->addHTML( "</div>\n" );
290  }
291 
292  // Byte limit (not string length limit) for wpReason and wpNewTitleMain
293  // is enforced in the mediawiki.special.movePage module
294 
295  $immovableNamespaces = [];
296  foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
297  if ( !MWNamespace::isMovable( $nsId ) ) {
298  $immovableNamespaces[] = $nsId;
299  }
300  }
301 
302  $handler = ContentHandler::getForTitle( $this->oldTitle );
303 
304  $out->enableOOUI();
305  $fields = [];
306 
307  $fields[] = new OOUI\FieldLayout(
308  new MediaWiki\Widget\ComplexTitleInputWidget( [
309  'id' => 'wpNewTitle',
310  'namespace' => [
311  'id' => 'wpNewTitleNs',
312  'name' => 'wpNewTitleNs',
313  'value' => $newTitle->getNamespace(),
314  'exclude' => $immovableNamespaces,
315  ],
316  'title' => [
317  'id' => 'wpNewTitleMain',
318  'name' => 'wpNewTitleMain',
319  'value' => $wgContLang->recodeForEdit( $newTitle->getText() ),
320  // Inappropriate, since we're expecting the user to input a non-existent page's title
321  'suggestions' => false,
322  ],
323  'infusable' => true,
324  ] ),
325  [
326  'label' => $this->msg( 'newtitle' )->text(),
327  'align' => 'top',
328  ]
329  );
330 
331  $fields[] = new OOUI\FieldLayout(
332  new OOUI\TextInputWidget( [
333  'name' => 'wpReason',
334  'id' => 'wpReason',
335  'maxLength' => 200,
336  'infusable' => true,
337  'value' => $this->reason,
338  ] ),
339  [
340  'label' => $this->msg( 'movereason' )->text(),
341  'align' => 'top',
342  ]
343  );
344 
345  if ( $considerTalk ) {
346  $fields[] = new OOUI\FieldLayout(
347  new OOUI\CheckboxInputWidget( [
348  'name' => 'wpMovetalk',
349  'id' => 'wpMovetalk',
350  'value' => '1',
351  'selected' => $this->moveTalk,
352  ] ),
353  [
354  'label' => $this->msg( 'movetalk' )->text(),
355  'help' => new OOUI\HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
356  'align' => 'inline',
357  'infusable' => true,
358  ]
359  );
360  }
361 
362  if ( $user->isAllowed( 'suppressredirect' ) ) {
363  if ( $handler->supportsRedirects() ) {
364  $isChecked = $this->leaveRedirect;
365  $isDisabled = false;
366  } else {
367  $isChecked = false;
368  $isDisabled = true;
369  }
370  $fields[] = new OOUI\FieldLayout(
371  new OOUI\CheckboxInputWidget( [
372  'name' => 'wpLeaveRedirect',
373  'id' => 'wpLeaveRedirect',
374  'value' => '1',
375  'selected' => $isChecked,
376  'disabled' => $isDisabled,
377  ] ),
378  [
379  'label' => $this->msg( 'move-leave-redirect' )->text(),
380  'align' => 'inline',
381  ]
382  );
383  }
384 
385  if ( $hasRedirects ) {
386  $fields[] = new OOUI\FieldLayout(
387  new OOUI\CheckboxInputWidget( [
388  'name' => 'wpFixRedirects',
389  'id' => 'wpFixRedirects',
390  'value' => '1',
391  'selected' => $this->fixRedirects,
392  ] ),
393  [
394  'label' => $this->msg( 'fix-double-redirects' )->text(),
395  'align' => 'inline',
396  ]
397  );
398  }
399 
400  if ( $canMoveSubpage ) {
401  $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
402  $fields[] = new OOUI\FieldLayout(
403  new OOUI\CheckboxInputWidget( [
404  'name' => 'wpMovesubpages',
405  'id' => 'wpMovesubpages',
406  'value' => '1',
407  # Don't check the box if we only have talk subpages to
408  # move and we aren't moving the talk page.
409  'selected' => $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ),
410  ] ),
411  [
412  'label' => new OOUI\HtmlSnippet(
413  $this->msg(
414  ( $this->oldTitle->hasSubpages()
415  ? 'move-subpages'
416  : 'move-talk-subpages' )
417  )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
418  ),
419  'align' => 'inline',
420  ]
421  );
422  }
423 
424  # Don't allow watching if user is not logged in
425  if ( $user->isLoggedIn() ) {
426  $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
427  || $user->isWatched( $this->oldTitle ) );
428  $fields[] = new OOUI\FieldLayout(
429  new OOUI\CheckboxInputWidget( [
430  'name' => 'wpWatch',
431  'id' => 'watch', # ew
432  'value' => '1',
433  'selected' => $watchChecked,
434  ] ),
435  [
436  'label' => $this->msg( 'move-watch' )->text(),
437  'align' => 'inline',
438  ]
439  );
440  }
441 
442  $hiddenFields = '';
443  if ( $moveOverShared ) {
444  $hiddenFields .= Html::hidden( 'wpMoveOverSharedFile', '1' );
445  }
446 
447  if ( $deleteAndMove ) {
448  $fields[] = new OOUI\FieldLayout(
449  new OOUI\CheckboxInputWidget( [
450  'name' => 'wpDeleteAndMove',
451  'id' => 'wpDeleteAndMove',
452  'value' => '1',
453  ] ),
454  [
455  'label' => $this->msg( 'delete_and_move_confirm' )->text(),
456  'align' => 'inline',
457  ]
458  );
459  }
460 
461  $fields[] = new OOUI\FieldLayout(
462  new OOUI\ButtonInputWidget( [
463  'name' => 'wpMove',
464  'value' => $this->msg( 'movepagebtn' )->text(),
465  'label' => $this->msg( 'movepagebtn' )->text(),
466  'flags' => [ 'constructive', 'primary' ],
467  'type' => 'submit',
468  ] ),
469  [
470  'align' => 'top',
471  ]
472  );
473 
474  $fieldset = new OOUI\FieldsetLayout( [
475  'label' => $this->msg( 'move-page-legend' )->text(),
476  'id' => 'mw-movepage-table',
477  'items' => $fields,
478  ] );
479 
480  $form = new OOUI\FormLayout( [
481  'method' => 'post',
482  'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
483  'id' => 'movepage',
484  ] );
485  $form->appendContent(
486  $fieldset,
487  new OOUI\HtmlSnippet(
488  $hiddenFields .
489  Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
490  Html::hidden( 'wpEditToken', $user->getEditToken() )
491  )
492  );
493 
494  $out->addHTML(
495  new OOUI\PanelLayout( [
496  'classes' => [ 'movepage-wrapper' ],
497  'expanded' => false,
498  'padded' => true,
499  'framed' => true,
500  'content' => $form,
501  ] )
502  );
503 
504  $this->showLogFragment( $this->oldTitle );
505  $this->showSubpages( $this->oldTitle );
506  }
507 
508  function doSubmit() {
509  $user = $this->getUser();
510 
511  if ( $user->pingLimiter( 'move' ) ) {
512  throw new ThrottledError;
513  }
514 
515  $ot = $this->oldTitle;
516  $nt = $this->newTitle;
517 
518  # don't allow moving to pages with # in
519  if ( !$nt || $nt->hasFragment() ) {
520  $this->showForm( [ [ 'badtitletext' ] ] );
521 
522  return;
523  }
524 
525  # Show a warning if the target file exists on a shared repo
526  if ( $nt->getNamespace() == NS_FILE
527  && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
528  && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
529  && wfFindFile( $nt )
530  ) {
531  $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
532 
533  return;
534  }
535 
536  # Delete to make way if requested
537  if ( $this->deleteAndMove ) {
538  $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
539  if ( count( $permErrors ) ) {
540  # Only show the first error
541  $this->showForm( $permErrors );
542 
543  return;
544  }
545 
546  $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
547 
548  // Delete an associated image if there is
549  if ( $nt->getNamespace() == NS_FILE ) {
550  $file = wfLocalFile( $nt );
551  $file->load( File::READ_LATEST );
552  if ( $file->exists() ) {
553  $file->delete( $reason, false, $user );
554  }
555  }
556 
557  $error = ''; // passed by ref
558  $page = WikiPage::factory( $nt );
559  $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
560  if ( !$deleteStatus->isGood() ) {
561  $this->showForm( $deleteStatus->getErrorsArray() );
562 
563  return;
564  }
565  }
566 
568 
569  if ( !$handler->supportsRedirects() ) {
570  $createRedirect = false;
571  } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
572  $createRedirect = $this->leaveRedirect;
573  } else {
574  $createRedirect = true;
575  }
576 
577  # Do the actual move.
578  $mp = new MovePage( $ot, $nt );
579  $valid = $mp->isValidMove();
580  if ( !$valid->isOK() ) {
581  $this->showForm( $valid->getErrorsArray() );
582  return;
583  }
584 
585  $permStatus = $mp->checkPermissions( $user, $this->reason );
586  if ( !$permStatus->isOK() ) {
587  $this->showForm( $permStatus->getErrorsArray() );
588  return;
589  }
590 
591  $status = $mp->move( $user, $this->reason, $createRedirect );
592  if ( !$status->isOK() ) {
593  $this->showForm( $status->getErrorsArray() );
594  return;
595  }
596 
597  if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects ) {
598  DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
599  }
600 
601  $out = $this->getOutput();
602  $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
603 
604  $oldLink = Linker::link(
605  $ot,
606  null,
607  [ 'id' => 'movepage-oldlink' ],
608  [ 'redirect' => 'no' ]
609  );
610  $newLink = Linker::linkKnown(
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  Hooks::run( 'SpecialMovepageAfterMove', [ &$this, &$ot, &$nt ] );
634 
635  # Now we move extra pages we've been asked to move: subpages and talk
636  # pages. First, if the old page or the new page is a talk page, we
637  # can't move any talk pages: cancel that.
638  if ( $ot->isTalkPage() || $nt->isTalkPage() ) {
639  $this->moveTalk = false;
640  }
641 
642  if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
643  $this->moveSubpages = false;
644  }
645 
657  // @todo FIXME: Use Title::moveSubpages() here
658  $dbr = wfGetDB( DB_MASTER );
659  if ( $this->moveSubpages && (
660  MWNamespace::hasSubpages( $nt->getNamespace() ) || (
661  $this->moveTalk
662  && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
663  )
664  ) ) {
665  $conds = [
666  'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
667  . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
668  ];
669  $conds['page_namespace'] = [];
670  if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
671  $conds['page_namespace'][] = $ot->getNamespace();
672  }
673  if ( $this->moveTalk &&
674  MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
675  ) {
676  $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
677  }
678  } elseif ( $this->moveTalk ) {
679  $conds = [
680  'page_namespace' => $ot->getTalkPage()->getNamespace(),
681  'page_title' => $ot->getDBkey()
682  ];
683  } else {
684  # Skip the query
685  $conds = null;
686  }
687 
688  $extraPages = [];
689  if ( !is_null( $conds ) ) {
690  $extraPages = TitleArray::newFromResult(
691  $dbr->select( 'page',
692  [ 'page_id', 'page_namespace', 'page_title' ],
693  $conds,
694  __METHOD__
695  )
696  );
697  }
698 
699  $extraOutput = [];
700  $count = 1;
701  foreach ( $extraPages as $oldSubpage ) {
702  if ( $ot->equals( $oldSubpage ) || $nt->equals( $oldSubpage ) ) {
703  # Already did this one.
704  continue;
705  }
706 
707  $newPageName = preg_replace(
708  '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
709  StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
710  $oldSubpage->getDBkey()
711  );
712 
713  if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
714  // Moving a subpage from a subject namespace to a talk namespace or vice-versa
715  $newNs = $nt->getNamespace();
716  } elseif ( $oldSubpage->isTalkPage() ) {
717  $newNs = $nt->getTalkPage()->getNamespace();
718  } else {
719  $newNs = $nt->getSubjectPage()->getNamespace();
720  }
721 
722  # Bug 14385: we need makeTitleSafe because the new page names may
723  # be longer than 255 characters.
724  $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
725  if ( !$newSubpage ) {
726  $oldLink = Linker::linkKnown( $oldSubpage );
727  $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
728  ->params( Title::makeName( $newNs, $newPageName ) )->escaped();
729  continue;
730  }
731 
732  # This was copy-pasted from Renameuser, bleh.
733  if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
734  $link = Linker::linkKnown( $newSubpage );
735  $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
736  } else {
737  $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
738 
739  if ( $success === true ) {
740  if ( $this->fixRedirects ) {
741  DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
742  }
743  $oldLink = Linker::link(
744  $oldSubpage,
745  null,
746  [],
747  [ 'redirect' => 'no' ]
748  );
749 
750  $newLink = Linker::linkKnown( $newSubpage );
751  $extraOutput[] = $this->msg( 'movepage-page-moved' )
752  ->rawParams( $oldLink, $newLink )->escaped();
753  ++$count;
754 
755  $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
756  if ( $count >= $maximumMovedPages ) {
757  $extraOutput[] = $this->msg( 'movepage-max-pages' )
758  ->numParams( $maximumMovedPages )->escaped();
759  break;
760  }
761  } else {
762  $oldLink = Linker::linkKnown( $oldSubpage );
763  $newLink = Linker::link( $newSubpage );
764  $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
765  ->rawParams( $oldLink, $newLink )->escaped();
766  }
767  }
768  }
769 
770  if ( $extraOutput !== [] ) {
771  $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
772  }
773 
774  # Deal with watches (we don't watch subpages)
775  WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user );
776  WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user );
777  }
778 
779  function showLogFragment( $title ) {
780  $moveLogPage = new LogPage( 'move' );
781  $out = $this->getOutput();
782  $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
784  }
785 
786  function showSubpages( $title ) {
787  if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
788  return;
789  }
790 
791  $subpages = $title->getSubpages();
792  $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
793 
794  $out = $this->getOutput();
795  $out->wrapWikiMsg( '== $1 ==', [ 'movesubpage', $count ] );
796 
797  # No subpages.
798  if ( $count == 0 ) {
799  $out->addWikiMsg( 'movenosubpage' );
800 
801  return;
802  }
803 
804  $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
805  $out->addHTML( "<ul>\n" );
806 
807  foreach ( $subpages as $subpage ) {
808  $link = Linker::link( $subpage );
809  $out->addHTML( "<li>$link</li>\n" );
810  }
811  $out->addHTML( "</ul>\n" );
812  }
813 
822  public function prefixSearchSubpages( $search, $limit, $offset ) {
823  return $this->prefixSearchString( $search, $limit, $offset );
824  }
825 
826  protected function getGroupName() {
827  return 'pagetools';
828  }
829 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
static fixRedirects($reason, $redirTitle, $destTitle=false)
Insert jobs into the job queue to fix redirects to the given title.
#define the
table suitable for use with IDatabase::select()
static isMovable($index)
Can pages in the given namespace be moved?
Definition: MWNamespace.php:67
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
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:762
Shortcut to construct a special page which is unlisted by default.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
Handles the backend logic of moving a page from one title to another.
Definition: MovePage.php:28
string $reason
Text input.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
$success
getText()
Get the text form (spaces not underscores) of the main part.
Definition: Title.php:893
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
showSubpages($title)
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:759
msg()
Wrapper around wfMessage that sets the current context.
static escapeRegexReplacement($string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter...
getOutput()
Get the OutputPage being used for this instance.
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:1449
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
A helper class for throttling authentication attempts.
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
wfLocalFile($title)
Get an object referring to a locally registered file.
The TitleArray class only exists to provide the newFromResult method at pre- sent.
Definition: TitleArray.php:31
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition: hooks.txt:2581
Class to simplify the use of log pages.
Definition: LogPage.php:32
static addCallableUpdate($callable, $type=self::POSTSEND)
Add a callable update.
showForm($err)
Show the form.
isValidMoveOperation(&$nt, $auth=true, $reason= '')
Check whether a given move operation would be valid.
Definition: Title.php:3636
An error page which can definitely be safely rendered using the OutputPage.
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:59
const NS_CATEGORY
Definition: Defines.php:83
getSkin()
Shortcut to get the skin being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
const DB_SLAVE
Definition: Defines.php:46
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
static hasSubpages($index)
Does the namespace allow subpages?
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:934
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:12
const NS_FILE
Definition: Defines.php:75
static newFromResult($res)
Definition: TitleArray.php:38
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
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
Definition: distributors.txt:9
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:242
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:195
quickUserCan($action, $user=null)
Can $user perform $action on this page? This skips potentially expensive cascading permission checks ...
Definition: Title.php:1904
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:35
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getUser()
Shortcut to get the User executing this instance.
static makeName($ns, $title, $fragment= '', $interwiki= '', $canonicalNamespace=false)
Make a prefixed DB key from a DB key and a namespace index.
Definition: Title.php:738
A special page that allows users to change page titles.
getConfig()
Shortcut to get main config object.
Show an error when a user tries to do something they do not have the necessary permissions for...
getLanguage()
Shortcut to get user's language.
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:1004
showLogFragment($title)
prefixSearchSubpages($search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition: design.txt:56
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:1004
$count
const DB_MASTER
Definition: Defines.php:47
getRequest()
Get the WebRequest being used for this instance.
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:762
static doWatchOrUnwatch($watch, Title $title, User $user)
Watch or unwatch a page.
Definition: WatchAction.php:83
prefixSearchString($search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
wfFindFile($title, $options=[])
Find a file.
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:2338
Show an error when the user hits a rate limit.
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:2338
getPageTitle($subpage=false)
Get a self-referential title object.