In https://www.drupal.org/project/drupal/issues/2692373, the behaviour when throwing a MigrateSkipProcessException was changed so that the value is reset to NULL.

I have a use case in which I want the value to be retained, and can't see a way to accomplish this with the current code. I am migrating users, and seeking to retain accounts that were registered in the last 2 weeks or have a last access time in the last 2 weeks (yes, that's not long - as you'll see below I'm using 1 year while testing). I've created a 'SkipOnTimestampCondition' process plugin and am using it as follows:

  created:
    -
      plugin: get
      source: created
    -
      plugin: skip_on_timestamp_condition
      method: process
      operator: '>='
      interval: '1 YEAR AGO'
    -
      plugin: skip_on_timestamp_condition
      method: row
      source: access
      operator: '<'
      interval: '1 YEAR AGO'
    -
      plugin: get
      source: created
  access:
    -
      plugin: get
      source: access
    -
      plugin: skip_on_empty
      method: process
    -
      plugin: skip_on_timestamp_condition
      method: row
      operator: <=
      interval: '1 YEAR AGO'

This is working fine apart from the fact that if the creation time is >= a year ago, the created time gets reset to NULL rather than having the value from the source retained.

I can think of two possibilities that don't modify the API in a non-backwards compatible way:

1) Implement a new exception that doesn't NULL the value.
2) Add an optional argument to the existing exception, indicating whether to null the value (default true).

Is there a preference, or can someone else see a way around this issue that I've not found yet?

TIA!

Thanks in advance for any replies.

Comments

NigelCunningham created an issue. See original summary.

pobster’s picture

Category: Feature request » Support request
Priority: Normal » Minor

Just don't use it, assign it to something else ~ the source value will still exist;

process:
  # Note this is the shorthand version of the "get" plugin.
  stash_created: created
  created:
      plugin: skip_on_timestamp_condition
      method: process
      source: '@stash_created'
      operator: '>='
      interval: '1 YEAR AGO'
    -
      plugin: skip_on_timestamp_condition
      method: row
      source: access
      operator: '<'
      interval: '1 YEAR AGO'
nigelcunningham’s picture

Status: Active » Closed (works as designed)

Thanks very much for the different approach.

For the sake of anyone who might come across a similar issue in future, here's my final version:

  created: created
  access: access
  skip_old_not_accessed_recently:
    -
      plugin: skip_on_timestamp_condition
      source: 'created'
      operator: '>='
      interval: '2 WEEKS AGO'
      method: process
    -
      plugin: skip_on_timestamp_condition
      source: access
      operator: '<'
      interval: '2 WEEKS AGO'
      method: row