$this->db->fieldExists( 'updatelog', 'ul_value', __METHOD__ );
}
+ /**
+ * Returns whether updates should be executed on the database table $name.
+ * Updates will be prevented if the table is a shared table and it is not
+ * specified to run updates on shared tables.
+ *
+ * @param $name String table name
+ * @return bool
+ */
+ protected function doTable( $name ) {
+ global $wgSharedDB, $wgSharedTables;
+
+ // Don't bother to check $wgSharedTables if there isn't a shared database
+ // or the user actually also wants to do updates on the shared database.
+ if ( $wgSharedDB === null || $this->shared ) {
+ return true;
+ }
+
+ return !in_array( $name, $wgSharedTables );
+ }
+
/**
* Before 1.17, we used to handle updates via stuff like
* $wgExtNewTables/Fields/Indexes. This is nasty :) We refactored a lot
*/
protected function getOldGlobalUpdates() {
global $wgExtNewFields, $wgExtNewTables, $wgExtModifiedFields,
- $wgExtNewIndexes, $wgSharedDB, $wgSharedTables;
-
- $doUser = $this->shared ?
- $wgSharedDB && in_array( 'user', $wgSharedTables ) :
- !$wgSharedDB || !in_array( 'user', $wgSharedTables );
+ $wgExtNewIndexes;
$updates = array();
}
foreach ( $wgExtNewFields as $fieldRecord ) {
- if ( $fieldRecord[0] != 'user' || $doUser ) {
- $updates[] = array(
- 'addField', $fieldRecord[0], $fieldRecord[1],
- $fieldRecord[2], true
- );
- }
+ $updates[] = array(
+ 'addField', $fieldRecord[0], $fieldRecord[1],
+ $fieldRecord[2], true
+ );
}
foreach ( $wgExtNewIndexes as $fieldRecord ) {
* @return Boolean false if this was skipped because schema changes are skipped
*/
protected function addTable( $name, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $name ) ) {
+ return true;
+ }
+
if ( $this->db->tableExists( $name, __METHOD__ ) ) {
$this->output( "...$name table already exists.\n" );
} else {
* @return Boolean false if this was skipped because schema changes are skipped
*/
protected function addField( $table, $field, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
$this->output( "...$table table does not exist, skipping new field patch.\n" );
} elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
* @return Boolean false if this was skipped because schema changes are skipped
*/
protected function addIndex( $table, $index, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
$this->output( "...skipping: '$table' table doesn't exist yet.\n" );
return false;
* @return Boolean false if this was skipped because schema changes are skipped
*/
protected function dropField( $table, $field, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
return $this->applyPatch( $patch, $fullpath, "Table $table contains $field field. Dropping" );
} else {
* @return Boolean false if this was skipped because schema changes are skipped
*/
protected function dropIndex( $table, $index, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
return $this->applyPatch( $patch, $fullpath, "Dropping $index index from table $table" );
} else {
* @return Boolean false if this was skipped because schema changes are skipped
*/
public function dropTable( $table, $patch = false, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
if ( $this->db->tableExists( $table, __METHOD__ ) ) {
$msg = "Dropping table $table";
* @return Boolean false if this was skipped because schema changes are skipped
*/
public function modifyField( $table, $field, $patch, $fullpath = false ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
$updateKey = "$table-$field-$patch";
if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
$this->output( "...$table table does not exist, skipping modify field patch.\n" );
* @param $patchFile String: path to the patch to correct the field
*/
protected function checkBin( $table, $field, $patchFile ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
$tableName = $this->db->tableName( $table );
$res = $this->db->query( "SELECT $field FROM $tableName LIMIT 0", __METHOD__ );
$flags = explode( ' ', mysql_field_flags( $res->result, 0 ) );
* @return Boolean
*/
protected function indexHasField( $table, $index, $field ) {
+ if ( !$this->doTable( $table ) ) {
+ return true;
+ }
+
$info = $this->db->indexInfo( $table, $index, __METHOD__ );
if ( $info ) {
foreach ( $info as $row ) {
protected function doInterwikiUpdate() {
global $IP;
+ if ( !$this->doTable( 'interwiki' ) ) {
+ return true;
+ }
+
if ( $this->db->tableExists( "interwiki", __METHOD__ ) ) {
$this->output( "...already have interwiki table\n" );
return;
}
protected function doUserUniqueUpdate() {
+ if ( !$this->doTable( 'user' ) ) {
+ return true;
+ }
+
$duper = new UserDupes( $this->db, array( $this, 'output' ) );
if ( $duper->hasUniqueIndex() ) {
$this->output( "...already have unique user_name index.\n" );
}
protected function doUserGroupsUpdate() {
+ if ( !$this->doTable( 'user_groups' ) ) {
+ return true;
+ }
+
if ( $this->db->tableExists( 'user_groups', __METHOD__ ) ) {
$info = $this->db->fieldInfo( 'user_groups', 'ug_group' );
if ( $info->type() == 'int' ) {
protected function doEnableProfiling() {
global $wgProfileToDatabase;
+
+ if ( !$this->doTable( 'profiling' ) ) {
+ return true;
+ }
+
if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) {
$this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
}
}
protected function doMaybeProfilingMemoryUpdate() {
+ if ( !$this->doTable( 'profiling' ) ) {
+ return true;
+ }
+
if ( !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
return true;
} elseif ( $this->db->fieldExists( 'profiling', 'pf_memory', __METHOD__ ) ) {
}
protected function doUserNewTalkTimestampNotNull() {
+ if ( !$this->doTable( 'user_newtalk' ) ) {
+ return true;
+ }
+
$info = $this->db->fieldInfo( 'user_newtalk', 'user_last_timestamp' );
if ( $info === false ) {
return;