);
/**
- * Hooks that are used for outputting exceptions
- * Format is:
- * $wgExceptionHooks[] = $funcname
+ * Hooks that are used for outputting exceptions. Format is:
+ * $wgExceptionHooks[] = $funcname
* or:
- * $wgExceptionHooks[] = array( $class, $funcname )
+ * $wgExceptionHooks[] = array( $class, $funcname )
* Hooks should return strings or false
*/
$wgExceptionHooks = array();
/**
- * Page property link table invalidation lists.
- * Should only be set by extensions.
+ * Page property link table invalidation lists. Should only be set by exten-
+ * sions.
*/
$wgPagePropLinkInvalidations = array(
'hiddencat' => 'categorylinks',
$wgMaxRedirectLinksRetrieved = 500;
/**
- * Maximum number of calls to expensive parser functions
- * such as PAGESINCATEGORY.
+ * Maximum number of calls per parse to expensive parser functions such as
+ * PAGESINCATEGORY.
*/
$wgExpensiveParserFunctionLimit = 100;
+/**
+ * Maximum number of pages to move at once when moving subpages with a page.
+ */
+$wgMaximumMovedPages = 1000;
+
/**
* Array of namespaces to generate a sitemap for when the
- * maintenance/generateSitemap.php script is run, or false
- * if one is to be generated for all namespaces.
+ * maintenance/generateSitemap.php script is run, or false if one is to be ge-
+ * nerated for all namespaces.
*/
$wgSitemapNamespaces = false;
/**
- * If user doesn't specify any edit summary when making a an edit,
- * MediaWiki will try to automatically create one. This feature can
- * be disabled by setting this variable false.
+ * If user doesn't specify any edit summary when making a an edit, MediaWiki
+ * will try to automatically create one. This feature can be disabled by set-
+ * ting this variable false.
*/
-$wgUseAutomaticEditSummaries = true;
\ No newline at end of file
+$wgUseAutomaticEditSummaries = true;
$f = new MovePageForm( $par );
- if ( 'success' == $action ) {
- $f->showSuccess();
- } else if ( 'submit' == $action && $wgRequest->wasPosted()
+ if ( 'submit' == $action && $wgRequest->wasPosted()
&& $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
$f->doSubmit();
} else {
*/
class MovePageForm {
var $oldTitle, $newTitle, $reason; # Text input
- var $moveTalk, $deleteAndMove;
+ var $moveTalk, $deleteAndMove, $moveSubpages;
private $watch = false;
} else {
$this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true );
}
+ $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false );
$this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
$this->watch = $wgRequest->getCheck( 'wpWatch' );
}
function showForm( $err, $hookErr = '' ) {
- global $wgOut, $wgUser;
+ global $wgOut, $wgUser, $wgNamespacesWithSubpages;
$ot = Title::newFromURL( $this->oldTitle );
if( is_null( $ot ) ) {
</tr>"
);
- if ( $considerTalk ) {
+ if( $considerTalk ) {
$wgOut->addHTML( "
<tr>
<td></td>
);
}
+ if( $ot->hasSubpages() || $ot->getTalkPage()->hasSubpages() ) {
+ $wgOut->addHTML( "
+ <tr>
+ <td></td>
+ <td class=\"mw-input\">" .
+ Xml::checkLabel( wfMsgHtml(
+ $ot->hasSubpages()
+ ? 'move-subpages'
+ : 'move-talk-subpages'
+ ),
+ 'wpMovesubpages', 'wpMovesubpages',
+ # Don't check the box if we only have talk subpages to
+ # move and we aren't moving the talk page.
+ $this->moveSubpages && ($ot->hasSubpages() || $this->moveTalk)
+ ) .
+ "</td>
+ </tr>"
+ );
+ }
+
$watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching();
$wgOut->addHTML( "
<tr>
wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
- # Move the talk page if relevant, if it exists, and if we've been told to
- $ott = $ot->getTalkPage();
- if( $ott->exists() ) {
- if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
- $ntt = $nt->getTalkPage();
-
- # Attempt the move
- $error = $ott->moveTo( $ntt, true, $this->reason );
- if ( $error === true ) {
- $talkmoved = 1;
- wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) );
- } else {
- $talkmoved = $error;
- }
+ $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) );
+
+ $oldUrl = $ot->getFullUrl( 'redirect=no' );
+ $newUrl = $nt->getFullUrl();
+ $oldText = $ot->getPrefixedText();
+ $newText = $nt->getPrefixedText();
+ $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>";
+ $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>";
+
+ $wgOut->addWikiMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
+
+ # 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
+ # can't move any talk pages: cancel that.
+ if( $ot->isTalkPage() || $nt->isTalkPage() ) {
+ $this->moveTalk = false;
+ }
+
+ # Next make a list of id's. This might be marginally less efficient
+ # than a more direct method, but this is not a highly performance-cri-
+ # tical code path and readable code is more important here.
+ #
+ # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
+ # 4 might get confused. If so, consider rewriting as a UNION.
+ $dbr = wfGetDB( DB_SLAVE );
+ if( $this->moveSubpages ) {
+ $conds = array(
+ 'page_title LIKE '.$dbr->addQuotes( $dbr->escapeLike( $ot->getDBkey() ) . '/%' )
+ .' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
+ );
+ if( $this->moveTalk ) {
+ $conds['page_namespace'] = array( $ot->getNamespace(),
+ MWNamespace::getTalk($ot->getNamespace()) );
} else {
- # Stay silent on the subject of talk.
- $talkmoved = '';
+ $conds['page_namespace'] = $ot->getNamespace();
}
} else {
- $talkmoved = 'notalkpage';
+ if( $this->moveTalk ) {
+ $conds = array(
+ 'page_namespace' => MWNamespace::getTalk($ot->getNamespace()),
+ 'page_title' => $ot->getDBKey()
+ );
+ } else {
+ # Skip the query
+ $conds = null;
+ }
}
- # Deal with watches
- if( $this->watch ) {
- $wgUser->addWatch( $ot );
- $wgUser->addWatch( $nt );
- } else {
- $wgUser->removeWatch( $ot );
- $wgUser->removeWatch( $nt );
+ if( !is_null( $conds ) ) {
+ $extrapages = $dbr->select(
+ 'page',
+ array( 'page_id', 'page_namespace', 'page_title' ),
+ $conds,
+ __METHOD__
+ );
}
- # Give back result to user.
- $titleObj = SpecialPage::getTitleFor( 'Movepage' );
- $success = $titleObj->getFullURL(
- 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
- '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
- '&talkmoved='.$talkmoved );
-
- $wgOut->redirect( $success );
- }
-
- function showSuccess() {
- global $wgOut, $wgRequest, $wgUser;
+ global $wgMaximumMovedPages, $wgLang;
+ $extraOutput = array();
+ $skin = $wgUser->getSkin();
+ $count = 1;
+ foreach( $extrapages as $row ) {
+ if( $row->page_id == $ot->getArticleId() ) {
+ # Already did this one.
+ continue;
+ }
- $old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) );
- $new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) );
+ $oldPage = Title::newFromRow( $row );
+ $newPageName = preg_replace(
+ '#^'.preg_quote( $ot->getDBKey(), '#' ).'#',
+ $nt->getDBKey(),
+ $oldPage->getDBKey()
+ );
+ # The following line is an atrocious hack. Kill it with fire.
+ $newNs = $nt->getNamespace() + ($oldPage->getNamespace() & 1);
+ $newPage = Title::makeTitle( $newNs, $newPageName );
+
+ # This was copy-pasted from Renameuser, bleh.
+ if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) {
+ $link = $skin->makeKnownLinkObj( $newPage );
+ $extraOutput []= wfMsgHtml( 'movepage-page-exists', $link );
+ } else {
+ $success = $oldPage->moveTo( $newPage, true, $this->reason );
+ if( $success === true ) {
+ $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' );
+ $newLink = $skin->makeKnownLinkObj( $newPage );
+ $extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink );
+ } else {
+ $oldLink = $skin->makeKnownLinkObj( $oldPage );
+ $newLink = $skin->makeLinkObj( $newPage );
+ $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink );
+ }
+ }
- if( is_null( $old ) || is_null( $new ) ) {
- throw new ErrorPageError( 'badtitle', 'badtitletext' );
+ ++$count;
+ if( $count >= $wgMaximumMovedPages ) {
+ $extraOutput []= wfMsgHtml( 'movepage-max-pages', $wgLang->formatNum( $wgMaximumMovedPages ) );
+ break;
+ }
}
- $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) );
-
- $talkmoved = $wgRequest->getVal( 'talkmoved' );
- $oldUrl = $old->getFullUrl( 'redirect=no' );
- $newUrl = $new->getFullUrl();
- $oldText = $old->getPrefixedText();
- $newText = $new->getPrefixedText();
- $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>";
- $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>";
-
- $s = wfMsgNoTrans( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
+ if( $extraOutput !== array() ) {
+ $wgOut->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
+ }
- if ( $talkmoved == 1 ) {
- $s .= "\n\n" . wfMsgNoTrans( 'talkpagemoved' );
- } elseif( 'articleexists' == $talkmoved ) {
- $s .= "\n\n" . wfMsgNoTrans( 'talkexists' );
+ # Deal with watches (we don't watch subpages)
+ if( $this->watch ) {
+ $wgUser->addWatch( $ot );
+ $wgUser->addWatch( $nt );
} else {
- if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) {
- $s .= "\n\n" . wfMsgNoTrans( 'talkpagenotmoved', wfMsgNoTrans( $talkmoved ) );
- }
+ $wgUser->removeWatch( $ot );
+ $wgUser->removeWatch( $nt );
}
- $wgOut->addWikiText( $s );
}
function showLogFragment( $title, &$out ) {