Moved drop_index_if_exists() to DatabaseUpdater and renamed it to dropIndex() for...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 11 Sep 2010 15:20:39 +0000 (15:20 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 11 Sep 2010 15:20:39 +0000 (15:20 +0000)
includes/installer/DatabaseUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/SqliteUpdater.php
maintenance/updaters.inc

index 0110235..6ed2ef1 100644 (file)
@@ -328,6 +328,24 @@ abstract class DatabaseUpdater {
                }
        }
 
+       /**
+        * Drop an index from an existing table
+        *
+        * @param $table String: Name of the table to modify
+        * @param $index String: Name of the old index
+        * @param $patch String: Path to the patch file
+        * @param $fullpath Boolean: Whether to treat $patch path as a relative or not
+        */
+       function dropIndex( $table, $index, $patch, $fullpath = false ) {
+               if ( $this->db->indexExists( $table, $index ) ) {
+                       wfOut( "Dropping $index from table $table... " );
+                       $this->applyPatch( $patch, $fullpath );
+                       wfOut( "ok\n" );
+               } else {
+                       wfOut( "...$index key doesn't exist.\n" );
+               }
+       }
+
        /**
         * Modify an existing field
         *
index efb4f5c..b7e16cc 100644 (file)
@@ -162,8 +162,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from',  'patch-rename-iwl_prefix.sql' ),
                        array( 'addField', 'updatelog', 'ul_value',              'patch-ul_value.sql' ),
                        array( 'addField', 'interwiki',     'iw_api',           'patch-iw_api_and_wikiid.sql' ),
-                       array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix',  'patch-kill-iwl_prefix.sql' ),
-                       array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
+                       array( 'dropIndex', 'iwlinks', 'iwl_prefix',  'patch-kill-iwl_prefix.sql' ),
+                       array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
                        array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
                        array( 'do_cl_fields_update' ),
                        array( 'do_collation_update' ),
index ce88f0e..b2f0de3 100644 (file)
@@ -45,8 +45,8 @@ class SqliteUpdater extends DatabaseUpdater {
                        array( 'addIndex', 'iwlinks',   'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
                        array( 'addField', 'updatelog', 'ul_value',              'patch-ul_value.sql' ),
                        array( 'addField', 'interwiki',     'iw_api',           'patch-iw_api_and_wikiid.sql' ),
-                       array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix',  'patch-kill-iwl_prefix.sql' ),
-                       array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
+                       array( 'dropIndex', 'iwlinks', 'iwl_prefix',  'patch-kill-iwl_prefix.sql' ),
+                       array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
                        array( 'addTable', 'msg_resource',                      'patch-msg_resource.sql' ),
                        array( 'addTable', 'module_deps',                       'patch-module_deps.sql' ),
                );
index f74c015..5d28cc1 100644 (file)
@@ -9,21 +9,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
        exit( 1 );
 }
 
-function drop_index_if_exists( $table, $index, $patch, $fullpath = false ) {
-       $dbw = wfGetDB( DB_MASTER );
-       if ( $dbw->indexExists( $table, $index ) ) {
-               wfOut( "Dropping $index from table $table... " );
-               if ( $fullpath ) {
-                       $dbw->sourceFile( $patch );
-               } else {
-                       $dbw->sourceFile( archive( $patch ) );
-               }
-               wfOut( "ok\n" );
-       } else {
-               wfOut( "...$index doesn't exist.\n" );
-       }
-}
-
 function archive( $name ) {
        return DatabaseBase::patchPath( $name );
 }