Skip to content

Commit

Permalink
Remove some row properties that cause unwanted content updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Jan 17, 2024
1 parent 3310f56 commit 104c0c2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion stanford_migrate.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Drupal\migrate_plus\Entity\Migration;
use Drupal\node\NodeInterface;
use Drupal\ultimate_cron\CronJobInterface;
Expand All @@ -31,6 +33,23 @@ function stanford_migrate_help($route_name, RouteMatchInterface $route_match) {
}
}

/**
* Implements hook_migrate_prepare_row().
*/
function stanford_migrate_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
// Oauth2 authentication adds a token query parameter into the data urls that changes frequently. Since it
// changes, the hash of the row changes without any data actually changing. Fix the row data so that it doesn't
// contain those tokens.
$authentication = $row->getSourceProperty('authentication/plugin');
$current_url = $row->getSourceProperty('current_feed_url');
if ($current_url && $authentication == 'oauth2') {
$row->setSourceProperty('current_feed_url', preg_replace('/access_token=.*?&/', '', $current_url));
}
// In case the list of urls changes dynamically, lets just remove it from the source data to avoid unnecessary hash
// changes.
$row->setSourceProperty('urls', []);
}

/**
* Get the migration that imported the given node.
*
Expand Down

0 comments on commit 104c0c2

Please sign in to comment.