$request = $this->getRequest();
$target = !is_null( $par ) ? $par : $request->getVal( 'target' );
- // Yes, the use of getVal() and getText() is wanted, see bug 20365
+ // Yes, the use of getVal() and getText() is wanted, see T22365
$oldTitleText = $request->getVal( 'wpOldTitle', $target );
$this->oldTitle = Title::newFromText( $oldTitleText );
// a redirect to the new title. This is not safe, but what we did before was
// even worse: we just determined whether a redirect should have been created,
// and reported that it was created if it should have, without any checks.
- // Also note that isRedirect() is unreliable because of bug 37209.
+ // Also note that isRedirect() is unreliable because of T39209.
$msgName = 'movepage-moved-redirect';
} else {
$msgName = 'movepage-moved-noredirect';
$newLink )->params( $oldText, $newText )->parseAsBlock() );
$out->addWikiMsg( $msgName );
- Hooks::run( 'SpecialMovepageAfterMove', [ &$this, &$ot, &$nt ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $movePage = $this;
+ Hooks::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
# Now we move extra pages we've been asked to move: subpages and talk
# pages. First, if the old page or the new page is a talk page, we
$newPageName = preg_replace(
'#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
- StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
+ StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # T23234
$oldSubpage->getDBkey()
);
$newNs = $nt->getSubjectPage()->getNamespace();
}
- # Bug 14385: we need makeTitleSafe because the new page names may
+ # T16385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
$newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
if ( !$newSubpage ) {
LogEventsList::showLogExtract( $out, 'move', $title );
}
+ /**
+ * Show subpages of the page being moved. Section is not shown if both current
+ * namespace does not support subpages and no talk subpages were found.
+ *
+ * @param Title $title Page being moved.
+ */
function showSubpages( $title ) {
- if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() );
+ $subpages = $title->getSubpages();
+ $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
+
+ $titleIsTalk = $title->isTalkPage();
+ $subpagesTalk = $title->getTalkPage()->getSubpages();
+ $countTalk = $subpagesTalk instanceof TitleArray ? $subpagesTalk->count() : 0;
+ $totalCount = $count + $countTalk;
+
+ if ( !$nsHasSubpages && $countTalk == 0 ) {
return;
}
- $subpages = $title->getSubpages();
- $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
+ $this->getOutput()->wrapWikiMsg(
+ '== $1 ==',
+ [ 'movesubpage', ( $titleIsTalk ? $count : $totalCount ) ]
+ );
+
+ if ( $nsHasSubpages ) {
+ $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
+ }
+ if ( !$titleIsTalk && $countTalk > 0 ) {
+ $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
+ }
+ }
+
+ function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
$out = $this->getOutput();
- $out->wrapWikiMsg( '== $1 ==', [ 'movesubpage', $count ] );
# No subpages.
- if ( $count == 0 ) {
+ if ( $pagecount == 0 && $noSubpageMsg ) {
$out->addWikiMsg( 'movenosubpage' );
-
return;
}
- $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
+ $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
$out->addHTML( "<ul>\n" );
$linkBatch = new LinkBatch( $subpages );
$linkBatch->setCaller( __METHOD__ );
$linkBatch->execute();
-
$linkRenderer = $this->getLinkRenderer();
+
foreach ( $subpages as $subpage ) {
$link = $linkRenderer->makeLink( $subpage );
$out->addHTML( "<li>$link</li>\n" );