Problem/Motivation

Looking at the code in MigrateExecutable, it looks like MigrateDestinationInterface::import() can throw a MigrateException.

Furthermore, while simply throwing a MigrateException causes the row to be considered to have failed, MigrateException's constructor allows a MigrateIdMapInterface status constant to be passed, so a destination plugin can do this to skip a row:

      throw new MigrateException("My message.", 0, NULL, MigrationInterface::MESSAGE_ERROR, MigrateIdMapInterface::STATUS_IGNORED);

This should be documented in MigrateDestinationInterface::import().

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3247039

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Active » Needs review
quietone’s picture

Status: Needs review » Needs work

@joachim, thanks for the MR.

Looking at the documentation for other @throws in core I find that many (or most?) begin with 'Thrown when ...'. I'd like to change to that form, it also reads better to me. Maybe this "Thrown when there is a problem importing the row." And instead of using the possessive form in the third sentence would this work? "However, any \Drupal\migrate\Plugin\MigrateIdMapInterface status constant can be set using the $status parameter of \Drupal\migrate\MigrateException." Or something like that?

quietone’s picture

Issue tags: +migrate

Adding tag for migrate maintainers

joachim’s picture

Status: Needs work » Needs review

Thanks for the review.

The documentation standards at https://www.drupal.org/docs/develop/standards/api-documentation-and-comm... say to use a complete sentence, so I don't think starting the sentence with 'Thrown when...' is right.

I've updated the bit about the parameter as suggested.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

@joachim, thank you. I didn't know that it was supposed to be a complete sentence. And thanks for removing the possessive form.

I have reread the changed documentation and think it is good to go now.

Thanks!

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 5592a5a5467 to 10.0.x and 5b9b5be27c3 to 9.4.x and 03d919b09d6 to 9.3.x. Thanks!

  • alexpott committed 5592a5a on 10.0.x
    Issue #3247039 by joachim, quietone: MigrateDestinationInterface::import...

  • alexpott committed 5b9b5be on 9.4.x
    Issue #3247039 by joachim, quietone: MigrateDestinationInterface::import...

  • alexpott committed 03d919b on 9.3.x
    Issue #3247039 by joachim, quietone: MigrateDestinationInterface::import...

Status: Fixed » Closed (fixed)

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