Index: branches/RL2/extensions/Gadgets/migrateGadgets.php |
— | — | @@ -50,7 +50,8 @@ |
51 | 51 | |
52 | 52 | $this->output( "Converting $id ...\n" ); |
53 | 53 | $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" |
55 | 56 | ); |
56 | 57 | foreach ( array_merge( $gadget['module']['scripts'], $gadget['module']['styles'] ) as $page ) { |
57 | 58 | $moves["MediaWiki:Gadget-$page"] = "Gadget:$page"; |
— | — | @@ -216,7 +217,28 @@ |
217 | 218 | |
218 | 219 | protected function processMoves( $moves, $reason ) { |
219 | 220 | $notMoved = array(); |
| 221 | + |
| 222 | + // Preprocessing step: add subpages |
| 223 | + $movesWithSubpages = array(); |
220 | 224 | 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 ) { |
221 | 243 | $result = $this->moveGadgetPage( $from, $to, $reason ); |
222 | 244 | if ( $result === true ) { |
223 | 245 | $this->output( "Moved [[$from]] to [[$to]]\n" ); |