Skip to content
Snippets Groups Projects
Verified Commit d82b6480 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3390693 by mikelutz, smustgrave:...

Issue #3390693 by mikelutz, smustgrave: MigrationPluginManager::ExpandPluginIds can lose derivative plugins under certain circumstances

(cherry picked from commit d5d6431e)
parent 2155f016
No related branches found
No related tags found
No related merge requests found
...@@ -145,7 +145,7 @@ public function expandPluginIds(array $migration_ids) { ...@@ -145,7 +145,7 @@ public function expandPluginIds(array $migration_ids) {
$plugin_ids = []; $plugin_ids = [];
$all_ids = array_keys($this->getDefinitions()); $all_ids = array_keys($this->getDefinitions());
foreach ($migration_ids as $id) { foreach ($migration_ids as $id) {
$plugin_ids += preg_grep('/^' . preg_quote($id, '/') . PluginBase::DERIVATIVE_SEPARATOR . '/', $all_ids); $plugin_ids = array_merge($plugin_ids, preg_grep('/^' . preg_quote($id, '/') . PluginBase::DERIVATIVE_SEPARATOR . '/', $all_ids));
if ($this->hasDefinition($id)) { if ($this->hasDefinition($id)) {
$plugin_ids[] = $id; $plugin_ids[] = $id;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Tests\migrate\Unit; namespace Drupal\Tests\migrate\Unit;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\migrate\Plugin\Migration; use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationPluginManager; use Drupal\migrate\Plugin\MigrationPluginManager;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
...@@ -65,6 +66,25 @@ public function testDependencyBuilding($migrations_data, $result_ids) { ...@@ -65,6 +66,25 @@ public function testDependencyBuilding($migrations_data, $result_ids) {
} }
} }
/**
* Tests that expandPluginIds returns all derivatives.
*/
public function testExpandPluginIds() {
$backend = $this->prophesize(CacheBackendInterface::class);
$cache = new \stdClass();
$cache->data = [
'a:a' => ['provider' => 'core'],
'a:b' => ['provider' => 'core'],
'b' => ['provider' => 'core'],
];
$backend->get('migration_plugins')->willReturn($cache);
$this->pluginManager->setCacheBackend($backend->reveal(), 'migration_plugins');
$plugin_ids = $this->pluginManager->expandPluginIds(['b', 'a']);
$this->assertContains('a:a', $plugin_ids);
$this->assertContains('a:b', $plugin_ids);
$this->assertContains('b', $plugin_ids);
}
/** /**
* Provide dependency data for testing. * Provide dependency data for testing.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment