Index: branches/RL2/extensions/Gadgets/Gadgets.php |
— | — | @@ -140,6 +140,7 @@ |
141 | 141 | $wgAutoloadClasses['GadgetOptionsResourceLoaderModule'] = $dir . 'backend/GadgetOptionsResourceLoaderModule.php'; |
142 | 142 | $wgAutoloadClasses['GadgetPrefs'] = $dir . 'backend/GadgetPrefs.php'; |
143 | 143 | $wgAutoloadClasses['LocalGadgetRepo'] = $dir . 'backend/LocalGadgetRepo.php'; |
| 144 | +$wgAutoloadClasses['MigrateGadgets'] = $dir . 'migrateGadgets.php'; |
144 | 145 | $wgAutoloadClasses['SpecialGadgets'] = $dir . 'SpecialGadgets.php'; |
145 | 146 | |
146 | 147 | $wgSpecialPages['Gadgets'] = 'SpecialGadgets'; |
Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php |
— | — | @@ -415,6 +415,7 @@ |
416 | 416 | $dir = dirname( __FILE__ ); |
417 | 417 | $updater->addExtensionUpdate( array( 'addtable', 'gadgets', "$dir/sql/gadgets.sql", true ) ); |
418 | 418 | $updater->addExtensionUpdate( array( 'addtable', 'gadgetpagelist', "$dir/sql/patch-gadgetpagelist.sql", true ) ); |
| 419 | + $updater->addPostDatabaseUpdateMaintenance( 'MigrateGadgets' ); |
419 | 420 | return true; |
420 | 421 | } |
421 | 422 | |
Index: branches/RL2/extensions/Gadgets/migrateGadgets.php |
— | — | @@ -1,20 +1,28 @@ |
2 | 2 | <?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if ( $IP === false ) { |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
| 3 | +// Prevent unnecessary path errors when run from update.php |
| 4 | +if ( !class_exists( 'Maintenance' ) ) { |
| 5 | + $IP = getenv( 'MW_INSTALL_PATH' ); |
| 6 | + if ( $IP === false ) { |
| 7 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 8 | + } |
| 9 | + require( "$IP/maintenance/Maintenance.php" ); |
7 | 10 | } |
8 | | -require( "$IP/maintenance/Maintenance.php" ); |
9 | 11 | |
10 | | -class MigrateGadgets extends Maintenance { |
| 12 | +class MigrateGadgets extends LoggedUpdateMaintenance { |
11 | 13 | public function __construct() { |
12 | 14 | parent::__construct(); |
13 | 15 | $this->mDescription = "Migrates old-style Gadgets defined in MediaWiki:Gadgets-definition to the new format"; |
14 | 16 | } |
15 | 17 | |
16 | | - public function execute() { |
17 | | - // TODO complain when we're being run twice, using update_log and --force |
18 | | - // TODO add this to the updaters |
| 18 | + protected function getUpdateKey() { |
| 19 | + return 'migrate gadgets'; |
| 20 | + } |
| 21 | + |
| 22 | + protected function updateSkippedMessage() { |
| 23 | + return 'Old-style Gadgets already migrated.'; |
| 24 | + } |
| 25 | + |
| 26 | + protected function doDBUpdates() { |
19 | 27 | global $wgUser; |
20 | 28 | $wgUser->setName( 'Gadget migration script' ); |
21 | 29 | $this->output( "Migrating old-style Gadgets from [[MediaWiki:Gadgets-definition]] ...\n" ); |
— | — | @@ -22,7 +30,7 @@ |
23 | 31 | $g = wfMessage( 'gadgets-definition' )->inContentLanguage(); |
24 | 32 | if ( !$g->exists() ) { |
25 | 33 | $this->output( "No Gadget definition page found.\n" ); |
26 | | - return; |
| 34 | + return false; |
27 | 35 | } |
28 | 36 | $wikitext = $g->plain(); |
29 | 37 | $gadgets = $this->parseGadgets( $wikitext ); |
— | — | @@ -70,6 +78,7 @@ |
71 | 79 | wfMessage( 'gadgets-migrate-movereason-category' )->inContentLanguage()->plain() |
72 | 80 | ) ); |
73 | 81 | |
| 82 | + $noErrors = count( $notMoved ) == 0 && count( $notCreated ) == 0; |
74 | 83 | if ( count( $notMoved ) ) { |
75 | 84 | $this->output( "There were ERRORS moving " . count( $notMoved ) . " pages.\n" ); |
76 | 85 | $this->output( "The following pages were NOT successfully moved:\n" ); |
— | — | @@ -84,6 +93,9 @@ |
85 | 94 | $this->output( "[[$page]]\n" ); |
86 | 95 | } |
87 | 96 | } |
| 97 | + if ( $noErrors ) { |
| 98 | + $this->output( "Gadgets migration finished without errors.\n" ); |
| 99 | + } |
88 | 100 | |
89 | 101 | if ( count( $notResourceLoaded ) ) { |
90 | 102 | $this->output( "WARNING: The following gadgets will now be loaded through ResourceLoader, but were not marked as supporting ResourceLoader. They may now be broken.\n" ); |
— | — | @@ -92,8 +104,8 @@ |
93 | 105 | } |
94 | 106 | } |
95 | 107 | |
96 | | - $this->output( "All done migrating gadgets\n" ); |
97 | | - |
| 108 | + $this->output( "All done migrating gadgets.\n" ); |
| 109 | + return $noErrors; |
98 | 110 | } |
99 | 111 | |
100 | 112 | /** |