reverted: --- b/core/modules/migrate/src/Plugin/Discovery/MigrateContainerDerivativeDiscoveryDecorator.php +++ /dev/null @@ -1,56 +0,0 @@ -moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - protected function getDeriver($base_plugin_id, $base_definition) { - // Short-circuit attempts to instantiate derivers if the base provider is - // not available. - if (isset($base_definition['provider']) && !in_array($base_definition['provider'], array('core', 'component')) && !$this->providerExists($base_definition['provider'])) { - return NULL; - } - else { - return parent::getDeriver($base_plugin_id, $base_definition); - } - } - - /** - * Determines if the provider of a definition exists. - * - * @return bool - * TRUE if provider exists, FALSE otherwise. - */ - protected function providerExists($provider) { - return $this->moduleHandler->moduleExists($provider); - } - -} diff -u b/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php --- b/core/modules/migrate/src/Plugin/MigrationPluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php @@ -12,7 +12,6 @@ use Drupal\Core\Plugin\Discovery\YamlDirectoryDiscovery; use Drupal\Core\Plugin\Factory\ContainerFactory; use Drupal\migrate\MigrateBuildDependencyInterface; -use Drupal\migrate\Plugin\Discovery\MigrateContainerDerivativeDiscoveryDecorator; /** * Plugin manager for migration plugins. @@ -69,7 +68,7 @@ }, $this->moduleHandler->getModuleDirectories()); $yaml_discovery = new YamlDirectoryDiscovery($directories, 'migrate'); - $this->discovery = new MigrateContainerDerivativeDiscoveryDecorator($yaml_discovery, $this->moduleHandler); + $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery, $this->moduleHandler); } return $this->discovery; } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php @@ -3,15 +3,43 @@ namespace Drupal\Core\Plugin\Discovery; use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator; +use Drupal\Component\Plugin\Discovery\DiscoveryInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; class ContainerDerivativeDiscoveryDecorator extends DerivativeDiscoveryDecorator { /** + * The module handler to validate the provider. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * Creates a new instance. + * + * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated + * The parent object implementing DiscoveryInterface that is being + * decorated. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function __construct(DiscoveryInterface $decorated, ModuleHandlerInterface $module_handler) { + parent::__construct($decorated); + $this->moduleHandler = $module_handler; + } + + /** * {@inheritdoc} */ protected function getDeriver($base_plugin_id, $base_definition) { if (!isset($this->derivers[$base_plugin_id])) { $this->derivers[$base_plugin_id] = FALSE; + // Validate the provider first, to avoid attempting to create a deriver + // dependent on the provider. + if (isset($base_definition['provider']) && !in_array($base_definition['provider'], array('core', 'component')) && !$this->providerExists($base_definition['provider'])) { + return NULL; + } $class = $this->getDeriverClass($base_definition); if ($class) { // If the deriver provides a factory method, pass the container to it. @@ -27,4 +55,14 @@ protected function getDeriver($base_plugin_id, $base_definition) { return $this->derivers[$base_plugin_id] ?: NULL; } + /** + * Determines if the provider of a definition exists. + * + * @return bool + * TRUE if provider exists, FALSE otherwise. + */ + protected function providerExists($provider) { + return $this->moduleHandler->moduleExists($provider); + } + }