Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -45,6 +45,8 @@ |
46 | 46 | displayed on the recent changes special pages. |
47 | 47 | * The "createpage" permission is no longer required when uploading if the target |
48 | 48 | image page already exists. |
| 49 | +* $wgMaximumMovedPages restricts the number of pages that can be moved at once |
| 50 | + (default 1000) with the new subpage-move functionality of Special:Movepage. |
49 | 51 | |
50 | 52 | === New features in 1.13 === |
51 | 53 | |
— | — | @@ -121,6 +123,7 @@ |
122 | 124 | * AutoAuthenticate hook renamed to UserLoadFromSession |
123 | 125 | * (bug 13232) importScript(), importStylesheet() funcs available to custom JS |
124 | 126 | * (bug 13095) Search by first letters or digits in [[Special:Categories]] |
| 127 | +* Users moving a page can now move all subpages automatically as well |
125 | 128 | |
126 | 129 | === Bug fixes in 1.13 === |
127 | 130 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1503,6 +1503,34 @@ |
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | /** |
| 1507 | + * Does this have subpages? (Warning, usually requires an extra DB query.) |
| 1508 | + * @return bool |
| 1509 | + */ |
| 1510 | + public function hasSubpages() { |
| 1511 | + global $wgNamespacesWithSubpages; |
| 1512 | + |
| 1513 | + if( !isset( $wgNamespacesWithSubpages[$this->mNamespace] ) ) { |
| 1514 | + # Duh |
| 1515 | + return false; |
| 1516 | + } |
| 1517 | + |
| 1518 | + # We dynamically add a member variable for the purpose of this method |
| 1519 | + # alone to cache the result. There's no point in having it hanging |
| 1520 | + # around uninitialized in every Title object; therefore we only add it |
| 1521 | + # if needed and don't declare it statically. |
| 1522 | + if( isset( $this->mHasSubpages ) ) { |
| 1523 | + return $this->mHasSubpages; |
| 1524 | + } |
| 1525 | + |
| 1526 | + $db = wfGetDB( DB_SLAVE ); |
| 1527 | + return $this->mHasSubpages = (bool)$db->selectField( 'page', '1', |
| 1528 | + "page_namespace = {$this->mNamespace} AND page_title LIKE '" |
| 1529 | + . $db->escapeLike( $this->mDbkeyform ) . "/%'", |
| 1530 | + __METHOD__ |
| 1531 | + ); |
| 1532 | + } |
| 1533 | + |
| 1534 | + /** |
1507 | 1535 | * Could this page contain custom CSS or JavaScript, based |
1508 | 1536 | * on the title? |
1509 | 1537 | * |
Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -30,9 +30,7 @@ |
31 | 31 | |
32 | 32 | $f = new MovePageForm( $par ); |
33 | 33 | |
34 | | - if ( 'success' == $action ) { |
35 | | - $f->showSuccess(); |
36 | | - } else if ( 'submit' == $action && $wgRequest->wasPosted() |
| 34 | + if ( 'submit' == $action && $wgRequest->wasPosted() |
37 | 35 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
38 | 36 | $f->doSubmit(); |
39 | 37 | } else { |
— | — | @@ -46,7 +44,7 @@ |
47 | 45 | */ |
48 | 46 | class MovePageForm { |
49 | 47 | var $oldTitle, $newTitle, $reason; # Text input |
50 | | - var $moveTalk, $deleteAndMove; |
| 48 | + var $moveTalk, $deleteAndMove, $moveSubpages; |
51 | 49 | |
52 | 50 | private $watch = false; |
53 | 51 | |
— | — | @@ -61,12 +59,13 @@ |
62 | 60 | } else { |
63 | 61 | $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); |
64 | 62 | } |
| 63 | + $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false ); |
65 | 64 | $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); |
66 | 65 | $this->watch = $wgRequest->getCheck( 'wpWatch' ); |
67 | 66 | } |
68 | 67 | |
69 | 68 | function showForm( $err, $hookErr = '' ) { |
70 | | - global $wgOut, $wgUser; |
| 69 | + global $wgOut, $wgUser, $wgNamespacesWithSubpages; |
71 | 70 | |
72 | 71 | $ot = Title::newFromURL( $this->oldTitle ); |
73 | 72 | if( is_null( $ot ) ) { |
— | — | @@ -180,7 +179,7 @@ |
181 | 180 | </tr>" |
182 | 181 | ); |
183 | 182 | |
184 | | - if ( $considerTalk ) { |
| 183 | + if( $considerTalk ) { |
185 | 184 | $wgOut->addHTML( " |
186 | 185 | <tr> |
187 | 186 | <td></td> |
— | — | @@ -191,6 +190,26 @@ |
192 | 191 | ); |
193 | 192 | } |
194 | 193 | |
| 194 | + if( $ot->hasSubpages() || $ot->getTalkPage()->hasSubpages() ) { |
| 195 | + $wgOut->addHTML( " |
| 196 | + <tr> |
| 197 | + <td></td> |
| 198 | + <td class=\"mw-input\">" . |
| 199 | + Xml::checkLabel( wfMsgHtml( |
| 200 | + $ot->hasSubpages() |
| 201 | + ? 'move-subpages' |
| 202 | + : 'move-talk-subpages' |
| 203 | + ), |
| 204 | + 'wpMovesubpages', 'wpMovesubpages', |
| 205 | + # Don't check the box if we only have talk subpages to |
| 206 | + # move and we aren't moving the talk page. |
| 207 | + $this->moveSubpages && ($ot->hasSubpages() || $this->moveTalk) |
| 208 | + ) . |
| 209 | + "</td> |
| 210 | + </tr>" |
| 211 | + ); |
| 212 | + } |
| 213 | + |
195 | 214 | $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching(); |
196 | 215 | $wgOut->addHTML( " |
197 | 216 | <tr> |
— | — | @@ -266,79 +285,119 @@ |
267 | 286 | |
268 | 287 | wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ; |
269 | 288 | |
270 | | - # Move the talk page if relevant, if it exists, and if we've been told to |
271 | | - $ott = $ot->getTalkPage(); |
272 | | - if( $ott->exists() ) { |
273 | | - if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) { |
274 | | - $ntt = $nt->getTalkPage(); |
| 289 | + $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) ); |
275 | 290 | |
276 | | - # Attempt the move |
277 | | - $error = $ott->moveTo( $ntt, true, $this->reason ); |
278 | | - if ( $error === true ) { |
279 | | - $talkmoved = 1; |
280 | | - wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ); |
281 | | - } else { |
282 | | - $talkmoved = $error; |
283 | | - } |
| 291 | + $oldUrl = $ot->getFullUrl( 'redirect=no' ); |
| 292 | + $newUrl = $nt->getFullUrl(); |
| 293 | + $oldText = $ot->getPrefixedText(); |
| 294 | + $newText = $nt->getPrefixedText(); |
| 295 | + $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>"; |
| 296 | + $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>"; |
| 297 | + |
| 298 | + $wgOut->addWikiMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText ); |
| 299 | + |
| 300 | + # Now we move extra pages we've been asked to move: subpages and talk |
| 301 | + # pages. First, if the old page or the new page is a talk page, we |
| 302 | + # can't move any talk pages: cancel that. |
| 303 | + if( $ot->isTalkPage() || $nt->isTalkPage() ) { |
| 304 | + $this->moveTalk = false; |
| 305 | + } |
| 306 | + |
| 307 | + # Next make a list of id's. This might be marginally less efficient |
| 308 | + # than a more direct method, but this is not a highly performance-cri- |
| 309 | + # tical code path and readable code is more important here. |
| 310 | + # |
| 311 | + # Note: this query works nicely on MySQL 5, but the optimizer in MySQL |
| 312 | + # 4 might get confused. If so, consider rewriting as a UNION. |
| 313 | + $dbr = wfGetDB( DB_SLAVE ); |
| 314 | + if( $this->moveSubpages ) { |
| 315 | + $conds = array( |
| 316 | + 'page_title LIKE '.$dbr->addQuotes( $dbr->escapeLike( $ot->getDBkey() ) . '/%' ) |
| 317 | + .' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() ) |
| 318 | + ); |
| 319 | + if( $this->moveTalk ) { |
| 320 | + $conds['page_namespace'] = array( $ot->getNamespace(), |
| 321 | + MWNamespace::getTalk($ot->getNamespace()) ); |
284 | 322 | } else { |
285 | | - # Stay silent on the subject of talk. |
286 | | - $talkmoved = ''; |
| 323 | + $conds['page_namespace'] = $ot->getNamespace(); |
287 | 324 | } |
288 | 325 | } else { |
289 | | - $talkmoved = 'notalkpage'; |
| 326 | + if( $this->moveTalk ) { |
| 327 | + $conds = array( |
| 328 | + 'page_namespace' => MWNamespace::getTalk($ot->getNamespace()), |
| 329 | + 'page_title' => $ot->getDBKey() |
| 330 | + ); |
| 331 | + } else { |
| 332 | + # Skip the query |
| 333 | + $conds = null; |
| 334 | + } |
290 | 335 | } |
291 | 336 | |
292 | | - # Deal with watches |
293 | | - if( $this->watch ) { |
294 | | - $wgUser->addWatch( $ot ); |
295 | | - $wgUser->addWatch( $nt ); |
296 | | - } else { |
297 | | - $wgUser->removeWatch( $ot ); |
298 | | - $wgUser->removeWatch( $nt ); |
| 337 | + if( !is_null( $conds ) ) { |
| 338 | + $extrapages = $dbr->select( |
| 339 | + 'page', |
| 340 | + array( 'page_id', 'page_namespace', 'page_title' ), |
| 341 | + $conds, |
| 342 | + __METHOD__ |
| 343 | + ); |
299 | 344 | } |
300 | 345 | |
301 | | - # Give back result to user. |
302 | | - $titleObj = SpecialPage::getTitleFor( 'Movepage' ); |
303 | | - $success = $titleObj->getFullURL( |
304 | | - 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) . |
305 | | - '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) . |
306 | | - '&talkmoved='.$talkmoved ); |
| 346 | + global $wgMaximumMovedPages, $wgLang; |
| 347 | + $extraOutput = array(); |
| 348 | + $skin = $wgUser->getSkin(); |
| 349 | + $count = 1; |
| 350 | + foreach( $extrapages as $row ) { |
| 351 | + if( $row->page_id == $ot->getArticleId() ) { |
| 352 | + # Already did this one. |
| 353 | + continue; |
| 354 | + } |
307 | 355 | |
308 | | - $wgOut->redirect( $success ); |
309 | | - } |
| 356 | + $oldPage = Title::newFromRow( $row ); |
| 357 | + $newPageName = preg_replace( |
| 358 | + '#^'.preg_quote( $ot->getDBKey(), '#' ).'#', |
| 359 | + $nt->getDBKey(), |
| 360 | + $oldPage->getDBKey() |
| 361 | + ); |
| 362 | + # The following line is an atrocious hack. Kill it with fire. |
| 363 | + $newNs = $nt->getNamespace() + ($oldPage->getNamespace() & 1); |
| 364 | + $newPage = Title::makeTitle( $newNs, $newPageName ); |
310 | 365 | |
311 | | - function showSuccess() { |
312 | | - global $wgOut, $wgRequest, $wgUser; |
| 366 | + # This was copy-pasted from Renameuser, bleh. |
| 367 | + if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) { |
| 368 | + $link = $skin->makeKnownLinkObj( $newPage ); |
| 369 | + $extraOutput []= wfMsgHtml( 'movepage-page-exists', $link ); |
| 370 | + } else { |
| 371 | + $success = $oldPage->moveTo( $newPage, true, $this->reason ); |
| 372 | + if( $success === true ) { |
| 373 | + $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' ); |
| 374 | + $newLink = $skin->makeKnownLinkObj( $newPage ); |
| 375 | + $extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink ); |
| 376 | + } else { |
| 377 | + $oldLink = $skin->makeKnownLinkObj( $oldPage ); |
| 378 | + $newLink = $skin->makeLinkObj( $newPage ); |
| 379 | + $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink ); |
| 380 | + } |
| 381 | + } |
313 | 382 | |
314 | | - $old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) ); |
315 | | - $new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) ); |
| 383 | + ++$count; |
| 384 | + if( $count >= $wgMaximumMovedPages ) { |
| 385 | + $extraOutput []= wfMsgHtml( 'movepage-max-pages', $wgLang->formatNum( $wgMaximumMovedPages ) ); |
| 386 | + break; |
| 387 | + } |
| 388 | + } |
316 | 389 | |
317 | | - if( is_null( $old ) || is_null( $new ) ) { |
318 | | - throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
| 390 | + if( $extraOutput !== array() ) { |
| 391 | + $wgOut->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" ); |
319 | 392 | } |
320 | 393 | |
321 | | - $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) ); |
322 | | - |
323 | | - $talkmoved = $wgRequest->getVal( 'talkmoved' ); |
324 | | - $oldUrl = $old->getFullUrl( 'redirect=no' ); |
325 | | - $newUrl = $new->getFullUrl(); |
326 | | - $oldText = $old->getPrefixedText(); |
327 | | - $newText = $new->getPrefixedText(); |
328 | | - $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>"; |
329 | | - $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>"; |
330 | | - |
331 | | - $s = wfMsgNoTrans( 'movepage-moved', $oldLink, $newLink, $oldText, $newText ); |
332 | | - |
333 | | - if ( $talkmoved == 1 ) { |
334 | | - $s .= "\n\n" . wfMsgNoTrans( 'talkpagemoved' ); |
335 | | - } elseif( 'articleexists' == $talkmoved ) { |
336 | | - $s .= "\n\n" . wfMsgNoTrans( 'talkexists' ); |
| 394 | + # Deal with watches (we don't watch subpages) |
| 395 | + if( $this->watch ) { |
| 396 | + $wgUser->addWatch( $ot ); |
| 397 | + $wgUser->addWatch( $nt ); |
337 | 398 | } else { |
338 | | - if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) { |
339 | | - $s .= "\n\n" . wfMsgNoTrans( 'talkpagenotmoved', wfMsgNoTrans( $talkmoved ) ); |
340 | | - } |
| 399 | + $wgUser->removeWatch( $ot ); |
| 400 | + $wgUser->removeWatch( $nt ); |
341 | 401 | } |
342 | | - $wgOut->addWikiText( $s ); |
343 | 402 | } |
344 | 403 | |
345 | 404 | function showLogFragment( $title, &$out ) { |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -3159,18 +3159,17 @@ |
3160 | 3160 | ); |
3161 | 3161 | |
3162 | 3162 | /** |
3163 | | - * Hooks that are used for outputting exceptions |
3164 | | - * Format is: |
3165 | | - * $wgExceptionHooks[] = $funcname |
| 3163 | + * Hooks that are used for outputting exceptions. Format is: |
| 3164 | + * $wgExceptionHooks[] = $funcname |
3166 | 3165 | * or: |
3167 | | - * $wgExceptionHooks[] = array( $class, $funcname ) |
| 3166 | + * $wgExceptionHooks[] = array( $class, $funcname ) |
3168 | 3167 | * Hooks should return strings or false |
3169 | 3168 | */ |
3170 | 3169 | $wgExceptionHooks = array(); |
3171 | 3170 | |
3172 | 3171 | /** |
3173 | | - * Page property link table invalidation lists. |
3174 | | - * Should only be set by extensions. |
| 3172 | + * Page property link table invalidation lists. Should only be set by exten- |
| 3173 | + * sions. |
3175 | 3174 | */ |
3176 | 3175 | $wgPagePropLinkInvalidations = array( |
3177 | 3176 | 'hiddencat' => 'categorylinks', |
— | — | @@ -3183,22 +3182,27 @@ |
3184 | 3183 | $wgMaxRedirectLinksRetrieved = 500; |
3185 | 3184 | |
3186 | 3185 | /** |
3187 | | - * Maximum number of calls to expensive parser functions |
3188 | | - * such as PAGESINCATEGORY. |
| 3186 | + * Maximum number of calls per parse to expensive parser functions such as |
| 3187 | + * PAGESINCATEGORY. |
3189 | 3188 | */ |
3190 | 3189 | $wgExpensiveParserFunctionLimit = 100; |
3191 | 3190 | |
3192 | 3191 | /** |
| 3192 | + * Maximum number of pages to move at once when moving subpages with a page. |
| 3193 | + */ |
| 3194 | +$wgMaximumMovedPages = 1000; |
| 3195 | + |
| 3196 | +/** |
3193 | 3197 | * Array of namespaces to generate a sitemap for when the |
3194 | | - * maintenance/generateSitemap.php script is run, or false |
3195 | | - * if one is to be generated for all namespaces. |
| 3198 | + * maintenance/generateSitemap.php script is run, or false if one is to be ge- |
| 3199 | + * nerated for all namespaces. |
3196 | 3200 | */ |
3197 | 3201 | $wgSitemapNamespaces = false; |
3198 | 3202 | |
3199 | 3203 | |
3200 | 3204 | /** |
3201 | | - * If user doesn't specify any edit summary when making a an edit, |
3202 | | - * MediaWiki will try to automatically create one. This feature can |
3203 | | - * be disabled by setting this variable false. |
| 3205 | + * If user doesn't specify any edit summary when making a an edit, MediaWiki |
| 3206 | + * will try to automatically create one. This feature can be disabled by set- |
| 3207 | + * ting this variable false. |
3204 | 3208 | */ |
3205 | | -$wgUseAutomaticEditSummaries = true; |
\ No newline at end of file |
| 3209 | +$wgUseAutomaticEditSummaries = true; |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2426,8 +2426,12 @@ |
2427 | 2427 | Please merge them manually.'''", |
2428 | 2428 | 'movedto' => 'moved to', |
2429 | 2429 | 'movetalk' => 'Move associated talk page', |
2430 | | -'talkpagemoved' => 'The corresponding talk page was also moved.', |
2431 | | -'talkpagenotmoved' => 'The corresponding talk page was <strong>not</strong> moved.', |
| 2430 | +'move-subpages' => 'Move all subpages, if applicable', |
| 2431 | +'move-talk-subpages' => 'Move all subpages of talk page, if applicable', |
| 2432 | +'movepage-page-exists' => 'The page $1 already exists and cannot be automatically overwritten.', |
| 2433 | +'movepage-page-moved' => 'The page $1 has been moved to $2.', |
| 2434 | +'movepage-page-unmoved' => 'The page $1 could not be moved to $2.', |
| 2435 | +'movepage-max-pages' => 'The maximum of $1 pages has been moved and no more will be moved automatically.', |
2432 | 2436 | '1movedto2' => '[[$1]] moved to [[$2]]', |
2433 | 2437 | '1movedto2_redir' => '[[$1]] moved to [[$2]] over redirect', |
2434 | 2438 | 'movelogpage' => 'Move log', |
Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1659,8 +1659,12 @@ |
1660 | 1660 | 'talkexists', |
1661 | 1661 | 'movedto', |
1662 | 1662 | 'movetalk', |
1663 | | - 'talkpagemoved', |
1664 | | - 'talkpagenotmoved', |
| 1663 | + 'move-subpages', |
| 1664 | + 'move-talk-subpages', |
| 1665 | + 'movepage-page-exists', |
| 1666 | + 'movepage-page-unmoved', |
| 1667 | + 'movepage-page-moved', |
| 1668 | + 'movepage-max-pages', |
1665 | 1669 | '1movedto2', |
1666 | 1670 | '1movedto2_redir', |
1667 | 1671 | 'movelogpage', |