r102850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102849‎ | r102850 | r102851 >
Date:09:56, 12 November 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Followup r102817: make the migration script inherit LoggedUpdateMaintenance (so it's only run once unless --force is used) and add it to the updaters. The latter requires r102849
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.hooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/Gadgets.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/migrateGadgets.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.php
@@ -140,6 +140,7 @@
141141 $wgAutoloadClasses['GadgetOptionsResourceLoaderModule'] = $dir . 'backend/GadgetOptionsResourceLoaderModule.php';
142142 $wgAutoloadClasses['GadgetPrefs'] = $dir . 'backend/GadgetPrefs.php';
143143 $wgAutoloadClasses['LocalGadgetRepo'] = $dir . 'backend/LocalGadgetRepo.php';
 144+$wgAutoloadClasses['MigrateGadgets'] = $dir . 'migrateGadgets.php';
144145 $wgAutoloadClasses['SpecialGadgets'] = $dir . 'SpecialGadgets.php';
145146
146147 $wgSpecialPages['Gadgets'] = 'SpecialGadgets';
Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php
@@ -415,6 +415,7 @@
416416 $dir = dirname( __FILE__ );
417417 $updater->addExtensionUpdate( array( 'addtable', 'gadgets', "$dir/sql/gadgets.sql", true ) );
418418 $updater->addExtensionUpdate( array( 'addtable', 'gadgetpagelist', "$dir/sql/patch-gadgetpagelist.sql", true ) );
 419+ $updater->addPostDatabaseUpdateMaintenance( 'MigrateGadgets' );
419420 return true;
420421 }
421422
Index: branches/RL2/extensions/Gadgets/migrateGadgets.php
@@ -1,20 +1,28 @@
22 <?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" );
710 }
8 -require( "$IP/maintenance/Maintenance.php" );
911
10 -class MigrateGadgets extends Maintenance {
 12+class MigrateGadgets extends LoggedUpdateMaintenance {
1113 public function __construct() {
1214 parent::__construct();
1315 $this->mDescription = "Migrates old-style Gadgets defined in MediaWiki:Gadgets-definition to the new format";
1416 }
1517
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() {
1927 global $wgUser;
2028 $wgUser->setName( 'Gadget migration script' );
2129 $this->output( "Migrating old-style Gadgets from [[MediaWiki:Gadgets-definition]] ...\n" );
@@ -22,7 +30,7 @@
2331 $g = wfMessage( 'gadgets-definition' )->inContentLanguage();
2432 if ( !$g->exists() ) {
2533 $this->output( "No Gadget definition page found.\n" );
26 - return;
 34+ return false;
2735 }
2836 $wikitext = $g->plain();
2937 $gadgets = $this->parseGadgets( $wikitext );
@@ -70,6 +78,7 @@
7179 wfMessage( 'gadgets-migrate-movereason-category' )->inContentLanguage()->plain()
7280 ) );
7381
 82+ $noErrors = count( $notMoved ) == 0 && count( $notCreated ) == 0;
7483 if ( count( $notMoved ) ) {
7584 $this->output( "There were ERRORS moving " . count( $notMoved ) . " pages.\n" );
7685 $this->output( "The following pages were NOT successfully moved:\n" );
@@ -84,6 +93,9 @@
8594 $this->output( "[[$page]]\n" );
8695 }
8796 }
 97+ if ( $noErrors ) {
 98+ $this->output( "Gadgets migration finished without errors.\n" );
 99+ }
88100
89101 if ( count( $notResourceLoaded ) ) {
90102 $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 @@
93105 }
94106 }
95107
96 - $this->output( "All done migrating gadgets\n" );
97 -
 108+ $this->output( "All done migrating gadgets.\n" );
 109+ return $noErrors;
98110 }
99111
100112 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r102852[RL2] In the spirit of r102850, also add populateGadgetPageList.php to the up...catrope10:04, 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
r102849Allow extensions to add post-update maintenance scriptscatrope09:55, 12 November 2011

Status & tagging log