From 18ab1c42737e38e3226ab0a04e10f922b5d3658e Mon Sep 17 00:00:00 2001 From: Nimish Gautam Date: Mon, 10 Aug 2009 23:06:59 +0000 Subject: [PATCH] created variable $wgExtModifiedFields for existing fields modified by extensions, created corresponding modify_field() function --- maintenance/updaters.inc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index c91a513a11..ab0a0cec5e 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -193,6 +193,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 +241,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 ) ) { @@ -1069,7 +1089,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 +1129,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!)..." ); -- 2.20.1