Skip to content

Commit

Permalink
Changed check for MRC to site.path, moved logger service intializatio…
Browse files Browse the repository at this point in the history
…n outside the importer loop, and cleaned up the if statement logic.
  • Loading branch information
Seth Hendrick committed Jan 22, 2025
1 parent 019453f commit 040c919
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docroot/modules/humsci/hs_migrate/hs_migrate.install
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ function hs_migrate_update_8007() {
'hs_d7_news'
];

// Get site name to prevent removing hs_d7_news from MRC.
$site_name = \Drupal::config('system.site')->get('name');
$is_mrc = str_contains($site_name, 'Mathematics Research Center');

$schema = \Drupal::database()->schema();
$logger = \Drupal::logger('hs_migrate');

// Get site path to prevent removing hs_d7_news from MRC.
$site_path = \Drupal::getContainer()->getParameter('site.path');
$is_mrc = $site_path == 'sites/mrc';

foreach ($unused_importers as $importer) {

if ($is_mrc && ($importer === 'hs_d7_news')) {
if ($is_mrc && $importer == 'hs_d7_news') {
continue;
}

Expand All @@ -116,7 +117,7 @@ function hs_migrate_update_8007() {
->getStorage('migration')
->load($importer);

if(is_null($migration)){
if(!$migration){
continue;
}

Expand All @@ -125,7 +126,7 @@ function hs_migrate_update_8007() {
$message = t('Deleted @config', [
'@config' => 'migrate_plus.migration.' . $importer,
]);
\Drupal::logger('hs_migrate')->notice($message);
$logger->notice($message);

// Drop migration database tables.
$migrate_map_table = 'migrate_map_' . $importer;
Expand All @@ -134,15 +135,15 @@ function hs_migrate_update_8007() {
$message = t('Dropped table @table', [
'@table' => $migrate_map_table,
]);
\Drupal::logger('hs_migrate')->notice($message);
$logger->notice($message);
}
$migrate_message_table = 'migrate_message_' . $importer;
if ($schema->tableExists($migrate_message_table)) {
$schema->dropTable($migrate_message_table);
$message = t('Dropped table @table', [
'@table' => $migrate_message_table,
]);
\Drupal::logger('hs_migrate')->notice($message);
$logger->notice($message);
}
}
}

0 comments on commit 040c919

Please sign in to comment.