Fix for r55810: oly set $optionsWithArgs if it's not defined, as in the old version...
[lhc/web/wiklou.git] / maintenance / updaters.inc
index 354ef44..fbc9893 100644 (file)
@@ -162,6 +162,8 @@ $wgUpdates = array(
                array( 'add_field', 'logging',       'log_user_text',  'patch-log_user_text.sql' ),
                array( 'add_table', 'l10n_cache',              'patch-l10n_cache.sql' ),
                array( 'add_table', 'external_user', 'patch-external_user.sql' ),
+               array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
+               array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
        ),
 
        'sqlite' => array(
@@ -193,6 +195,7 @@ $wgExtNewFields = array(); // table, column, dir
 $wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
 $wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
 $wgExtNewIndexes = array(); // table, index, dir
+$wgExtModifiedFields = array(); //table, index, dir
 
 # Helper function: check if the given key is present in the updatelog table.
 # Obviously, only use this for updates that occur after the updatelog table was
@@ -240,6 +243,25 @@ function add_table( $name, $patch, $fullpath=false ) {
        }
 }
 
+function modify_field($table, $field, $patch, $fullpath=false){
+       global $wgDatabase;
+       if ( !$wgDatabase->tableExists( $table ) ) {
+               wfOut( "...$table table does not exist, skipping modify field patch\n" );
+       } elseif (! $wgDatabase->fieldExists( $table, $field ) ) {
+               wfOut( "...$field field does not exist in $table table, skipping modify field patch\n" );
+       } else {
+               wfOut( "Modifying $field field of table $table..." );
+               if( $fullpath ) {
+                       $wgDatabase->sourceFile( $patch );
+               } else {
+                       $wgDatabase->sourceFile( archive($patch) );
+               }
+               wfOut( "ok\n" );
+       }
+}
+
+
+
 function add_field( $table, $field, $patch, $fullpath=false ) {
        global $wgDatabase;
        if ( !$wgDatabase->tableExists( $table ) ) {
@@ -984,6 +1006,7 @@ function index_has_field($table, $index, $field) {
 }
 
 function do_backlinking_indices_update() {
+       global $wgDatabase;
        wfOut( "Checking for backlinking indices...\n" );
        if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
                !index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
@@ -995,6 +1018,7 @@ function do_backlinking_indices_update() {
 }
 
 function do_categorylinks_indices_update() {
+       global $wgDatabase;
        wfOut( "Checking for categorylinks indices...\n" );
        if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
        {       
@@ -1040,7 +1064,7 @@ function do_stats_init() {
                wfOut( "ok.\n" );
                return;
        }
-       SiteStatsInit::doAllAndUpdate( false );
+       SiteStatsInit::doAllAndCommit( false );
 }
 
 function do_active_users_init() {
@@ -1069,7 +1093,7 @@ function purge_cache() {
 }
 
 function do_all_updates( $shared = false, $purge = true ) {
-       global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype, $IP;
+       global $wgNewTables, $wgExtModifiedFields, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype, $IP;
 
        wfRunHooks('LoadExtensionSchemaUpdates');
 
@@ -1109,6 +1133,11 @@ function do_all_updates( $shared = false, $purge = true ) {
                add_index( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2], true );
                flush();
        }
+       # Add modified extension fields
+       foreach ( $wgExtModifiedFields as $fieldRecord ) {
+               modify_field($fieldRecord[0], $fieldRecord[1], $fieldRecord[2], true);
+               flush();
+       }
 
 
        wfOut( "Deleting old default messages (this may take a long time!)..." );