diff -u b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php --- b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php @@ -53,19 +53,15 @@ * provider key that provider is guaranteed to exist. */ public static function filterDefinitions(array $definitions, callable $provider_exists) { - foreach ($definitions as $plugin_id => $plugin_definition) { - // If the plugin definition is an object, attempt to convert it to an - // array, if that is not possible, skip further processing. - if ((is_object($plugin_definition) && !($plugin_definition = (array) $plugin_definition)) || !isset($plugin_definition['provider'])) { - continue; - } - foreach ((array) $plugin_definition['provider'] as $provider) { - if (!in_array($provider, ['core', 'component']) && !$provider_exists($provider)) { - unset($definitions[$plugin_id]); - } - } + // Besides what the caller accepts, we also accept core or component. + $provider_exists = function ($provider) use ($provider_exists) { + return in_array($provider, ['core', 'component']) || $provider_exists($provider); } - return $definitions; + return array_filter($definitions, function ($definition) use ($provider_exists) { + $definition = (array) $definition + ['provider' => []]; + $providers = (array) $definition['provider']; + return count($providers) == count(array_filter($providers, $provider_exists)); + }); } /**