http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72782
Revision: 72782
Author: ialex
Date: 2010-09-11 08:35:39 +0000 (Sat, 11 Sep 2010)
Log Message:
-----------
Moved modify_field() from updaters.inc to DatabaseUpdater.php so that it can be
used with DatabaseUpdater::addExtensionUpdate()
Modified Paths:
--------------
trunk/phase3/includes/installer/DatabaseUpdater.php
trunk/phase3/maintenance/updaters.inc
Modified: trunk/phase3/includes/installer/DatabaseUpdater.php
===================================================================
--- trunk/phase3/includes/installer/DatabaseUpdater.php 2010-09-11 08:24:39 UTC
(rev 72781)
+++ trunk/phase3/includes/installer/DatabaseUpdater.php 2010-09-11 08:35:39 UTC
(rev 72782)
@@ -227,7 +227,7 @@
foreach ( $wgExtModifiedFields as $fieldRecord ) {
$updates[] = array(
- 'modify_field', $fieldRecord[0],
$fieldRecord[1],
+ 'modifyField', $fieldRecord[0], $fieldRecord[1],
$fieldRecord[2], true
);
}
@@ -329,6 +329,26 @@
}
/**
+ * 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
*/
protected function purgeCache() {
Modified: trunk/phase3/maintenance/updaters.inc
===================================================================
--- trunk/phase3/maintenance/updaters.inc 2010-09-11 08:24:39 UTC (rev
72781)
+++ trunk/phase3/maintenance/updaters.inc 2010-09-11 08:35:39 UTC (rev
72782)
@@ -9,23 +9,6 @@
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 ) ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs