MigrationPluginManager::ExpandPluginIds can lose derivative plugins under certain circumstances

Created on 29 September 2023, over 1 year ago
Updated 20 November 2023, about 1 year ago

Problem/Motivation

MigrationPluginManager::expandPluginIds() looks like this:

  protected function expandPluginIds(array $migration_ids) {
  /**
   * {@inheritdoc}
   */
  public function expandPluginIds(array $migration_ids) {
    $plugin_ids = [];
    $all_ids = array_keys($this->getDefinitions());
    foreach ($migration_ids as $id) {
      $plugin_ids += preg_grep('/^' . preg_quote($id, '/') . PluginBase::DERIVATIVE_SEPARATOR . '/', $all_ids);
      if ($this->hasDefinition($id)) {
        $plugin_ids[] = $id;
      }
    }
    return $plugin_ids;
  }

The array union operator works for the most part because preg_grep preserves the numeric keys of the $all_ids array, so there are no conflicts, but we also have a potential $plugin_ids[] = $id in the loop. If the original id's assigned index conflicts with a derivative id's index in a later iteration of the loop, the derivative id will not be added to the plugin id list.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
MigrationΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mikelutz Michigan, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024