Warning: Invalid argument supplied for foreach() in Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery->__construct() (line 42 of core\lib\Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery.php)

this patch provide checking

Comments

dudycz’s picture

Status: Needs review » Reviewed & tested by the community

I think it's ok

dries’s picture

dries’s picture

Somehow doesn't appear to apply on my local tree. May need a re-roll, but asked for a re-test to make sure.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, annotatedclassdiscovery-construct-empty-root-namespaces.patch, failed testing.

podarok’s picture

Status: Needs work » Needs review
StatusFileSize
new925 bytes

reroll

catch’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

I don't get this one.

$root_namespaces defaults to an array, foreaching over an empty array is fine. When it's explicitly set, it should be an array too.

So what's it getting set to?

podarok’s picture

Assigned: Unassigned » podarok
Issue tags: +Needs tests

ok, I`ll try to write test for this

webchick’s picture

Priority: Critical » Normal

Unless more details can be provided of when this happens, downgrading to normal.

podarok’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

this happens with EventSubscriber instance during changing arguments passed to __construct
working

public function __construct(ConfigFactory $configfactory, DomainBootstrap $domainbootstrap, ContextInterface $config_context) {

changed to

public function __construct(DomainBootstrap $domainbootstrap, ContextInterface $config_context, Request $request) {

drush cc all and got
Invalid argument supplied for foreach() in Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery->__construct()
container remembered old arguments passing ((...
The trouble was fixed with

rm -rf service_container_prod_.php
drush cc all

Looks like container regeneration needs deeper cleanup(and cleaning cache is not working here) when changing arguments with Bundle`s $container->register