http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72813

Revision: 72813
Author:   ialex
Date:     2010-09-11 15:20:39 +0000 (Sat, 11 Sep 2010)

Log Message:
-----------
Moved drop_index_if_exists() to DatabaseUpdater and renamed it to dropIndex() 
for consistency with dropField()

Modified Paths:
--------------
    trunk/phase3/includes/installer/DatabaseUpdater.php
    trunk/phase3/includes/installer/MysqlUpdater.php
    trunk/phase3/includes/installer/SqliteUpdater.php
    trunk/phase3/maintenance/updaters.inc

Modified: trunk/phase3/includes/installer/DatabaseUpdater.php
===================================================================
--- trunk/phase3/includes/installer/DatabaseUpdater.php 2010-09-11 15:02:44 UTC 
(rev 72812)
+++ trunk/phase3/includes/installer/DatabaseUpdater.php 2010-09-11 15:20:39 UTC 
(rev 72813)
@@ -329,6 +329,24 @@
        }
 
        /**
+        * 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
         *
         * @param $table String: name of the table to which the field belongs

Modified: trunk/phase3/includes/installer/MysqlUpdater.php
===================================================================
--- trunk/phase3/includes/installer/MysqlUpdater.php    2010-09-11 15:02:44 UTC 
(rev 72812)
+++ trunk/phase3/includes/installer/MysqlUpdater.php    2010-09-11 15:20:39 UTC 
(rev 72813)
@@ -162,8 +162,8 @@
                        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' ),

Modified: trunk/phase3/includes/installer/SqliteUpdater.php
===================================================================
--- trunk/phase3/includes/installer/SqliteUpdater.php   2010-09-11 15:02:44 UTC 
(rev 72812)
+++ trunk/phase3/includes/installer/SqliteUpdater.php   2010-09-11 15:20:39 UTC 
(rev 72813)
@@ -45,8 +45,8 @@
                        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' ),
                );

Modified: trunk/phase3/maintenance/updaters.inc
===================================================================
--- trunk/phase3/maintenance/updaters.inc       2010-09-11 15:02:44 UTC (rev 
72812)
+++ trunk/phase3/maintenance/updaters.inc       2010-09-11 15:20:39 UTC (rev 
72813)
@@ -9,21 +9,6 @@
        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 );
 }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to