You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using ApplicationConfigInjectionDelegator more than once (in multiple modules simultaneously) results results in a DuplicateRouteException. I found out about this after being contacted by a reader of Mezzio Essentials.
Current behavior
If you load the ApplicationConfigInjectionDelegator in more than one module in a Mezzio project, such as in the example below, in the module's ConfigProvider, then a DuplicateRouteException is thrown.
This happens because ApplicationConfigInjectionDelegator::injectRoutesFromConfig calls Mezzio\Application::route, which ultimately throws a DuplicateRouteException because it injectRoutesFromConfig doesn't check if a route is in the routing table before attempting to add the existing routing table to the routing table. I don't know if this is the intended functionality, but thought that if a route was added, that it would overwrite an existing one.
How to reproduce
Add the above code snippet in more than one module. You don't need to add any further configuration.
Expected behavior
That if there are no, actual, duplicate routes, that no DuplicateRouteException would be thrown.
The text was updated successfully, but these errors were encountered:
This is a tough one. Delegators are not meant to be used more than once.
What is the use-case of providing that delegator more than once?
The only thing to avoid this is to do some kind of de-duplication in laminas-servicemanager but I am unsure what kind of implications this might have in projects which do actually rely on this.
I, personally, can not imagine a use-case where delegators should be applied more than once to the same service.
Bug Report
Summary
Using
ApplicationConfigInjectionDelegator
more than once (in multiple modules simultaneously) results results in a DuplicateRouteException. I found out about this after being contacted by a reader of Mezzio Essentials.Current behavior
If you load the
ApplicationConfigInjectionDelegator
in more than one module in a Mezzio project, such as in the example below, in the module'sConfigProvider
, then aDuplicateRouteException
is thrown.This happens because
ApplicationConfigInjectionDelegator::injectRoutesFromConfig
callsMezzio\Application::route
, which ultimately throws aDuplicateRouteException
because itinjectRoutesFromConfig
doesn't check if a route is in the routing table before attempting to add the existing routing table to the routing table. I don't know if this is the intended functionality, but thought that if a route was added, that it would overwrite an existing one.How to reproduce
Add the above code snippet in more than one module. You don't need to add any further configuration.
Expected behavior
That if there are no, actual, duplicate routes, that no
DuplicateRouteException
would be thrown.The text was updated successfully, but these errors were encountered: