From: Alexandre Emsenhuber Date: Sat, 11 Sep 2010 08:35:39 +0000 (+0000) Subject: Moved modify_field() from updaters.inc to DatabaseUpdater.php so that it can be used... X-Git-Tag: 1.31.0-rc.0~35016 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=7346ee03c56a1294e4e975cd188de0793aa01e0c;p=lhc%2Fweb%2Fwiklou.git Moved modify_field() from updaters.inc to DatabaseUpdater.php so that it can be used with DatabaseUpdater::addExtensionUpdate() --- diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 33b5cb629d..bb240d1bdb 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -227,7 +227,7 @@ abstract class DatabaseUpdater { foreach ( $wgExtModifiedFields as $fieldRecord ) { $updates[] = array( - 'modify_field', $fieldRecord[0], $fieldRecord[1], + 'modifyField', $fieldRecord[0], $fieldRecord[1], $fieldRecord[2], true ); } @@ -328,6 +328,26 @@ abstract class DatabaseUpdater { } } + /** + * Modify an existing field + * + * @param $table String: name of the table to modify + * @param $field String: name of the old field + * @param $patch String: path to the patch file + * @param $fullpath Boolean: whether to treat $patch path as a relative or not + */ + public function modifyField( $table, $field, $patch, $fullpath = false ) { + if ( !$this->db->tableExists( $table ) ) { + wfOut( "...$table table does not exist, skipping modify field patch\n" ); + } elseif ( !$this->db->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..." ); + $this->applyPatch( $patch, $fullpath ); + wfOut( "ok\n" ); + } + } + /** * Purge the objectcache table */ diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index b657b6d134..def353088d 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -9,23 +9,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { exit( 1 ); } -function modify_field( $table, $field, $patch, $fullpath = false ) { - $dbw = wfGetDB( DB_MASTER ); - if ( !$dbw->tableExists( $table ) ) { - wfOut( "...$table table does not exist, skipping modify field patch\n" ); - } elseif ( !$dbw->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 ) { - $dbw->sourceFile( $patch ); - } else { - $dbw->sourceFile( archive( $patch ) ); - } - wfOut( "ok\n" ); - } -} - function drop_index_if_exists( $table, $index, $patch, $fullpath = false ) { $dbw = wfGetDB( DB_MASTER ); if ( $dbw->indexExists( $table, $index ) ) {