Problem/Motivation
Retrieving migrate messages is possible via \Drupal\migrate\Plugin\MigrateIdMapInterface::getMessages()
.
It allows to filter by one source item, providing its source IDs values, and if not provided, it returns all messages for the given ID map.
When trying to retrieve a set of messages corresponding to more than one source item, the only option is to retrieve the full set, and filter manually.
Here the method signature for reference.
public function getMessages(array $source_id_values = [], $level = NULL);
It is also important to mention that the ID map itself is an *iterable* object, that together with a custom filter iterator, e.g. migrate_tools' SourceFilter or drush's MigrateIdMapFilter, can be used to walk over a set of id maps.
Sadly, getMessages()
method does not take it into account the iterator, and retrieves data directly, e.g. at SQL ID map plugin , \Drupal\migrate\Plugin\migrate\id_map\Sql
; which makes sense for performance reasons.
BTW I noticed the problem while trying to extend one of the drush migrate commands that shows messages at Support idlist option on migrate:messages.
Steps to reproduce
N.A.
Proposed resolution
Add a new getMessagesSubset(array $source_id_values_list = [], $level = NULL)
method to \Drupal\migrate\Plugin\MigrateIdMapInterface
, that can receive multiple items to filter by.
E.g. for a source that has two source identifier keys like k1 and k2, where only three id map messages are wanted to be retrieved, the call would be similar to $id_map->getMessagesSubset([ ['k1' => 1, 'k2' => 1], ['k1' => 2, 'k2' => 1] ])
.
Since the changes adds a new method to a used interface, I guess the change needs to happen on 10.x, to avoid breaking any migrate ID map plugins in the wild during 9.x.
Remaining tasks
- Receive some feedback on the idea
- Write the needed changes, i.e. change the interface and core provided migrate Id map plugins
- Code review
User interface changes
N.A.
API changes
New getMessagesSubset()
method at \Drupal\migrate\Plugin\MigrateIdMapInterface
Data model changes
N.A.
Release notes snippet
TBD