r102854 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102853‎ | r102854 | r102855 >
Date:10:37, 12 November 2011
Author:catrope
Status:resolved
Tags:
Comment:
[RL2] Followup r102817: also move the talk page of the title message, and move the subpages of everything we're moving
Modified paths:
  • /branches/RL2/extensions/Gadgets/migrateGadgets.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/migrateGadgets.php
@@ -50,7 +50,8 @@
5151
5252 $this->output( "Converting $id ...\n" );
5353 $moves = array(
54 - "MediaWiki:Gadget-$id" => "MediaWiki:Gadget-$id-title"
 54+ "MediaWiki:Gadget-$id" => "MediaWiki:Gadget-$id-title",
 55+ "MediaWiki talk:Gadget-$id" => "MediaWiki talk:Gadget-$id-title"
5556 );
5657 foreach ( array_merge( $gadget['module']['scripts'], $gadget['module']['styles'] ) as $page ) {
5758 $moves["MediaWiki:Gadget-$page"] = "Gadget:$page";
@@ -216,7 +217,28 @@
217218
218219 protected function processMoves( $moves, $reason ) {
219220 $notMoved = array();
 221+
 222+ // Preprocessing step: add subpages
 223+ $movesWithSubpages = array();
220224 foreach ( $moves as $from => $to ) {
 225+ $title = Title::newFromText( $from );
 226+ if ( !$title ) {
 227+ continue;
 228+ }
 229+ $fromNormalized = $title->getPrefixedText();
 230+ $movesWithSubpages[$fromNormalized] = $to;
 231+ $subpages = $title->getSubpages();
 232+ foreach ( $subpages as $subpage ) {
 233+ $fromSub = $subpage->getPrefixedText();
 234+ //var_dump($fromSub);
 235+ $toSub = preg_replace( '/^' . preg_quote( $fromNormalized, '/' ) . '/',
 236+ StringUtils::escapeRegexReplacement( $to ), $fromSub
 237+ );
 238+ $movesWithSubpages[$fromSub] = $toSub;
 239+ }
 240+ }
 241+
 242+ foreach ( $movesWithSubpages as $from => $to ) {
221243 $result = $this->moveGadgetPage( $from, $to, $reason );
222244 if ( $result === true ) {
223245 $this->output( "Moved [[$from]] to [[$to]]\n" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r102855[RL2] Followup r102817: move the old title message to -desc instead of -title...catrope11:06, 12 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102817[RL2] Add maintenance script for migrating old-style gadgets to the new style...catrope21:49, 11 November 2011

Status & tagging log