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).

Comments

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(): http://cgit.drupalcode.org/address/tree/src/AddressServiceProvider.php

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.