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
5 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->)
Pipeline #52542 failed
Pipeline: drupal

#52546

    Pipeline: drupal

    #52545

      Pipeline: drupal

      #52544

        +1
        ...@@ -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.
        Please register or to comment