Problem/Motivation
Migrate source plugins use checkRequirements()
method and throw RequirementsException
to notify migration runners that migration requirements are not met.
However, if I run drush ms
for migration that doesn't meet the requirements, it won't show up in the list and I won't see any additional messages. If I add -vvv
flag, it's getting better:
[debug] Migration 'foo' is skipped as its source plugin has missed requirements: . [0.13 sec, 24.65 MB]
As we can see, it says the requirements are missing. By why? 🤷♂️
I looked at Drush code. They do this:
foreach ($migrations as $migrationId => $migration) {
try {
$sourcePlugin = $migration->getSourcePlugin();
if ($sourcePlugin instanceof RequirementsInterface) {
$sourcePlugin->checkRequirements();
}
} catch (RequirementsException $exception) {
$this->logger()->debug("Migration '{$migrationId}' is skipped as its source plugin has missed requirements: " . $exception->getRequirementsString());
unset($migrations[$migrationId]);
}
}
To get the details, they use only $exception->getRequirementsString()
. But according to Drupal\migrate\MigrateExecutable
, they should use $exception->getMessage()
as well:
$this->message->display(
$this->t(
'Migration @id did not meet the requirements. @message @requirements',
[
'@id' => $this->migration->id(),
'@message' => $e->getMessage(),
'@requirements' => $e->getRequirementsString(),
]
),
'error'
);
It should be fixed in Drush. Here is the issue: https://github.com/drush-ops/drush/pull/5052
Looks good so far, but do we really need to print @requirements array in that case? Here is current message:
Migration foo did not meet the requirements. The module bar is not enabled in the source site. source_module: bar
Why would we need to print source_module: bar
if there is a message that explains what is missing?
I think this should be enough: Migration @id did not meet the requirements. @message
.
It was introduced in #2321609: Provide a helpful message in case requirements are not met with the following comment:
I've put the requirements into the message in MigrateExecutable but it doesn't seem to be any additional information other than what the message already gives us at this point.
The author confirmed this list does not provide any additional data. Let's remove it then :)
Proposed resolution
1) Change the requirements message pattern from:
Migration foo did not meet the requirements. The module bar is not enabled in the source site. source_module: bar
To:
Migration foo did not meet the requirements. The module bar is not enabled in the source site.
2) Apply the same format in Drush: https://github.com/drush-ops/drush/pull/5052
Remaining tasks
Review / commit.