In the core skip_on_empty plugin there is an option to include a message:

  public function row($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!$value) {
      $message = !empty($this->configuration['message']) ? $this->configuration['message'] : '';
      throw new MigrateSkipRowException($message);
    }
    return $value;
  }

It would be nice if we could do the same for SkipOnValue.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
StatusFileSize
new2.95 KB
heddn’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Can we expand the tests to include this new optional feature?

marvil07’s picture

Version: 8.x-4.x-dev » 8.x-5.x-dev
StatusFileSize
new2.99 KB

Re-roll for 8.x-5.x

matroskeen’s picture

Issue tags: +LutskGCW22

While #3259591: Add generic Skip migrate process plugin with various operations is not ready yet, I think we can do it. Let's get some test examples from SkipOnEmptyTest and get this in ;)
We'll try to take care of it during the contribution weekend.

v.kydyba’s picture

Assigned: Unassigned » v.kydyba

v.kydyba’s picture

Status: Needs work » Needs review
v.kydyba’s picture

Assigned: v.kydyba » Unassigned
matroskeen’s picture

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

Thanks for the test, it looks great!

I noticed some inconsistency though. In SkipOnEmpty plugin the message is added only for 'row' method. This behavior matches the plugin description:

message: (optional) A message to be logged in the {migrate_message_*} table
for this row. Messages are only logged for the 'row' method. If not set,
nothing is logged in the message table.

In SkipOnValue the description is the same, but message is added also in 'process' method.

Is there any reason to add a message in 'process' method? I don't think so. Let's remove it and the update the tests.

  • v.kydyba committed 4816cfb on 8.x-5.x
    Issue #3015199: apply patch with new message feature
    
  • v.kydyba committed 81fa445 on 8.x-5.x
    Issue #3015199: remove message logging from process method, remove...
  • v.kydyba committed bb59520 on 8.x-5.x
    Issue #3015199: add tests for new message option
    
matroskeen’s picture

Status: Needs work » Fixed

Oops, it didn't squash commits properly 🙈

Anyway, now we have a message option that is aligned with SkipOnEmpty core plugin.
We also have test coverage, so let's get this in!

Thanks everyone!

Status: Fixed » Closed (fixed)

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

matroskeen’s picture

Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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