X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateLogSearch.php;h=e80b6f6665c5e4f0759840b187995f9607bd2f72;hb=beafc6a7f53e4db332cea1fc55e7293cde76684a;hp=589be48fa798932b225348b38084cc638732207a;hpb=f1d64e2fc641673c0b3c15a591b522f4ce813be9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 589be48fa7..e80b6f6665 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -117,15 +117,17 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $tables = [ self::$tableMap[$prefix] ]; $fields = []; $joins = []; - if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { + // Read the old fields if we're still writing them regardless of read mode, to handle upgrades $fields['userid'] = $prefix . '_user'; $fields['username'] = $prefix . '_user_text'; } - if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { + // Read the new fields if we're writing them regardless of read mode, to handle upgrades if ( $prefix === 'rev' ) { $tables[] = 'revision_actor_temp'; $joins['revision_actor_temp'] = [ - $wgActorTableSchemaMigrationStage === MIGRATION_NEW ? 'JOIN' : 'LEFT JOIN', + ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ? 'LEFT JOIN' : 'JOIN', 'rev_id = revactor_rev', ]; $fields['actorid'] = 'revactor_actor'; @@ -147,11 +149,13 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $log->addRelations( 'log_id', $items, $row->log_id ); // Query item author relations... $fields = []; - if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { + // Read the old fields if we're still writing them regardless of read mode, to handle upgrades $fields['userid'] = 'log_user'; $fields['username'] = 'log_user_text'; } - if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { + // Read the new fields if we're writing them regardless of read mode, to handle upgrades $fields['actorid'] = 'log_actor'; } @@ -163,14 +167,14 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { // Add item author relations... $userIds = $userIPs = $userActors = []; foreach ( $sres as $srow ) { - if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { if ( $srow->userid > 0 ) { $userIds[] = intval( $srow->userid ); } elseif ( $srow->username != '' ) { $userIPs[] = $srow->username; } } - if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { if ( $srow->actorid ) { $userActors[] = intval( $srow->actorid ); } elseif ( $srow->userid > 0 ) { @@ -181,11 +185,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { } } // Add item author relations... - if ( $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { $log->addRelations( 'target_author_id', $userIds, $row->log_id ); $log->addRelations( 'target_author_ip', $userIPs, $row->log_id ); } - if ( $wgActorTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { $log->addRelations( 'target_author_actor', $userActors, $row->log_id ); } }