there is an error if the module address is install, this error is generator when i access the admin/store and the site status

Recoverable fatal error: Argument 1 passed to Drupal\uc_country\CountryManager::__construct() must implement interface Drupal\Core\Extension\ModuleHandlerInterface, instance of Drupal\Core\Cache\DatabaseBackend given, called in /home/core/lib/Drupal/Component/DependencyInjection/Container.php on line 276 and defined in Drupal\uc_country\CountryManager->__construct() (line 40 of /home/modules/ubercart/uc_country/src/CountryManager.php).


RobertoGuzman created an issue. See original summary.

TR’s picture

Category: Bug report » Support request

The Drupal core country_manager service is implemented by \Drupal\Core\Locale\CountryManager.php, which defines a constructor with the signature public function __construct(ModuleHandlerInterface $module_handler)

Ubercart overrides the country_manager service in order to provide more information than core can provide (core only has iso2 country code and country English short name, while Ubercart provides the same thing plus iso3 codes, iso numeric codes, iso2 zone codes and zone names).

Ubercart does not alter the first (and by default only) argument to the country_manger service which is of type ModuleHandlerInterface, but Ubercart does add a second argument to the country_manager service. It appears that the Address module also alters the country_manager service. However, the core Drupal country_manager service requires that the first argument to the CountryManager constructor is of type ModuleHandlerInterface.

Ubercart is doing the correct thing here. I don't know who is calling CountryManager with a first argument of DatabaseBackend instead of ModuleHandlerInterface, but this is not happening within Ubercart. If the Address module is redefining the arguments of the country_manager service (rather than simply adding additional arguments), then the Address module is doing the wrong thing.

But fundamentally I think this is a problem with core Drupal architecture, which doesn't allow multiple modules to supply the same service (in this case country_manager).

RobertoGuzman’s picture

is there any work around to have both services at the same time ?

kiwad’s picture

Seems to be a duplicated tasks from #2664092: Addresses

longwave’s picture

Address calls setArguments() instead of addArgument():

But, do we really need to override the original service? We could just provide a separate service, that injects the original to obtain the list?

RobertoGuzman’s picture

any update relate to address and ubercart module ?

RobertoGuzman’s picture

any solution to this issue ?

RobertoGuzman’s picture

Issue summary: View changes
cbovard’s picture

Hello All, Was there any updates to this bug. I am getting the same as above.
Thank you everyone.

TR’s picture

As explained above, this is not an Ubercart bug. It's the Address module which improperly changes the arguments/signature of the core Drupal country_manager service. You should ask them to fix it.

dkre’s picture

This isn't user error so I'm not sure I would mark this as a support request.

I'm not very familiar with services by shouldn't decorators be the solution here? Symfony | Lullabot | Phase2

If CommerceGuys are not doing things in the best way with Address then surely it is better for a fellow module maintainer to post the issue than a site builder like me with very little understanding of what's happening under the hood. A good issue description leads to a quicker response and the issue being descibed from developer to developer a resolution will always be easier.

I can definitely understand your frustrations, it's not fun when external parties break things, but this module is DOA right now.

Re #5
addDefinition() resolves arg 1 error but then arg 2 produces an error: must implement Drupal\Core\Entity\EntityTypeManagerInterface.

dkre’s picture

Issue submitted on Address issue queue

TR’s picture

Status: Active » Fixed

In response to this issue, the Address module stopped their incorrect overriding of the core country_manager service. See #2866521: Stop overriding CountryManager. So this should no longer be a problem.

Status: Fixed » Closed (fixed)

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