Problem/Motivation

I have hit this bug in my pretty special use case.

The module I'm working on has two tagged services, the first one has been working well for a while but the second is a work in progress, however when testing something else I hit the following error PHP Fatal error: Uncaught Error: Call to a member function getName() on string in /core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php:116

After doing some digging in \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass::process I found that I should really be hitting the LogicException on line 110, but I wasn't because $interface was already set from the previous pass of the loop.

Proposed resolution

Set $interface to Null.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timmillwood created an issue. See original summary.

timmillwood’s picture

Assigned: plach » Unassigned
Status: Active » Needs review
FileSize
866 bytes

With the attached patch I am now hitting Symfony\Component\DependencyInjection\Exception\LogicException: Service consumer 'workspace.replication_manager' class method Drupal\workspace\Replication\ReplicationManager::addReplicator() has to type-hint an interface. in /core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php:111 which is correct.

dawehner’s picture

Nice find!

Is this something we can test?

timmillwood’s picture

Maybe, but I'm not sure if it's more work than it's worth.

dawehner’s picture

Well, we have a unit test already. I totally believe we can add support for more.

dawehner’s picture

The last submitted patch, 6: 2852515-6-test.patch, failed testing.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for writing the test @dawehner!

xjm’s picture

Title: $interface is still set from the previous loop » $interface is still set from the previous loop in tagged services compilation

  • xjm committed bbd96cc on 8.4.x
    Issue #2852515 by dawehner, timmillwood: $interface is still set from...

  • xjm committed 90bf31b on 8.3.x
    Issue #2852515 by dawehner, timmillwood: $interface is still set from...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Oopsie. Thanks! Committed to 8.4.x and cherry-picked to 8.3.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.