(bug 11451) Fix error in 1.2 -> 1.3 upgrade script, causing failure of upgrades from...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 14 May 2009 13:49:17 +0000 (13:49 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 14 May 2009 13:49:17 +0000 (13:49 +0000)
maintenance/archives/patch-fix-il_from.sql [new file with mode: 0644]
maintenance/updaters.inc

diff --git a/maintenance/archives/patch-fix-il_from.sql b/maintenance/archives/patch-fix-il_from.sql
new file mode 100644 (file)
index 0000000..0a199e4
--- /dev/null
@@ -0,0 +1,11 @@
+-- Fix a bug from the 1.2 -> 1.3 upgrader by moving away the imagelinks table
+-- and recreating it.
+RENAME TABLE /*_*/imagelinks TO /*_*/imagelinks_old;
+CREATE TABLE /*_*/imagelinks (
+  il_from int unsigned NOT NULL default 0,
+  il_to varchar(255) binary NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/il_from ON /*_*/imagelinks (il_from,il_to);
+CREATE UNIQUE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from);
+
index 69db8bf..72e510f 100644 (file)
@@ -38,6 +38,7 @@ $wgUpdates = array(
                array( 'add_table', 'categorylinks',                     'patch-categorylinks.sql' ),
                // do_linkscc_1_3_update obsolete
                array( 'do_old_links_update' ),
+               array( 'fix_ancient_imagelinks' ),
                array( 'add_field', 'recentchanges', 'rc_ip',            'patch-rc_ip.sql' ),
                
                // 1.4
@@ -784,6 +785,19 @@ function do_old_links_update() {
        }
 }
 
+function fix_ancient_imagelinks() {
+       global $wgDatabase;
+       $info = $wgDatabase->fieldInfo( 'imagelinks', 'il_from' );
+       if ( $info && $info->type() === 'string' ) {
+               wfOut( "Fixing ancient broken imagelinks table.\n" );
+               wfOut( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" );
+               dbsource( archive( 'patch-fix-il_from.sql' ) );
+               wfOut( "ok\n" );
+       } else {
+               wfOut( "...il_from OK\n" );
+       }
+}
+
 function do_user_unique_update() {
        global $wgDatabase;
        $duper = new UserDupes( $wgDatabase );