Skip to content

Commit

Permalink
Simplefied database update and selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
joegl committed Aug 22, 2024
1 parent dee7f2a commit 9fffdec
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions docroot/profiles/sdss/sdss_profile/sdss_profile.install
Original file line number Diff line number Diff line change
Expand Up @@ -929,27 +929,13 @@ function sdss_profile_update_10008() {
*/
function sdss_profile_update_10009(&$sandbox) {
if (!isset($sandbox['count'])) {
$migration_storage = \Drupal::entityTypeManager()->getStorage('migration');
if (!$migration_entity = $migration_storage->load('sdss_news_sharing')) {
$sandbox['#finished'] = 1;
return;
}

$sandbox['nids'] = [];
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_entity->id());
if (!$migration) {
$sandbox['#finished'] = 1;
return;
}

$database = $migration->getIdMap()->getDatabase();
$query = $database->select($migration->getIdMap()->mapTableName(), 'mt')
->fields('mt', ['destid1']);
$destination_records = $query->execute();
foreach ($destination_records as $destination_record) {
if (isset($destination_record->destid1)) {
$sandbox['nids'][] = $destination_record->destid1;
}
$db = \Drupal::database();
if ($db->schema()->tableExists('migrate_map_sdss_news_sharing')) {
$ids = array_keys($db->select('migrate_map_sdss_news_sharing', 'm')
->fields('m', ['destid1'])
->execute()
->fetchAllAssoc('destid1'));
$sandbox['nids'] = $ids;
}
$sandbox['count'] = count($sandbox['nids']);
}
Expand Down

0 comments on commit 9fffdec

Please sign in to comment.