Given the following input rows

id,type,title
1,blog,This is a blog post
2,page,This is a basic page
3,news,This is a news article
4,testimonial,This is a testimonial
...

I am trying to use SkipOnValue so that all rows where the type is news or blog are migrated ("skip row if type not in [blog,news]"). I figured the following configuration would work:

  type:
    -
      plugin: skip_on_value
      not_equals: true
      source: type
      method: row
      value:
        - "blog"
        - "news"

It doens't. The problem seems to be that SkipOnValue::compare is called against the import row for *each* of the configured values. So when the first row is processed, the source value "blog" is checked against the first configured value "blog". Since this comparison (not equals) returns FALSE, processing continues, and SkipOnValue goes on to compare the source value against the second configured value ("news"). Comparing ("not equals") the source value "blog" with configured value "news" *does* yield TRUE, and the row is skipped, even though the source value is in the list of configured values that should not be skipped.

Using this approach, it does not seem possible to use SkipOnValue to whitelist more than one value for which the row should not be skipped? Attached is a patch that alters the plugin so that it behaves like in_array or !in_array when multiple values are configured.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.baileys created an issue. See original summary.

mr.baileys’s picture

Issue tags: +Needs tests

The fact that tests pass with this patch means that additional test coverage is required.

heddn’s picture

Status: Needs review » Needs work

NW because needs tests :)

heddn’s picture

gnuget’s picture

Status: Needs work » Needs review
FileSize
3.37 KB
1.59 KB
2.59 KB

I faced this today so I decided to write the tests and I added support when the method is process instead of row

Patch, interdiff and only-test patch attached.

Status: Needs review » Needs work

The last submitted patch, 5: 2959775-5-tests-only.patch, failed testing. View results

gnuget’s picture

Status: Needs work » Needs review

  • heddn committed e0e5011 on 8.x-4.x authored by gnuget
    Issue #2959775 by gnuget, mr.baileys, heddn: SkipOnValue with multiple...
heddn’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.