The service "commerce_currencies.safe_early_order_processor" has a dependency on a non-existent service "commerce_shipping.early_order_processor"

Created on 25 July 2024, 5 months ago
Updated 27 August 2024, 4 months ago

Problem/Motivation

Right after enabling this module with drush, I get:

In DecoratorServicePass.php line 91:
The service "commerce_currencies.safe_early_order_processor" has a dependency on a non-existent service "commerce_shipping.early_order_processor".
Failed to run drush en commerce_currencies: exit status 1

This results in the module weirdly not being recognized as installed from drush, ie. if you try to drush pmu commerce_currencies right after you get The following module(s) are not installed: commerce_currencies. No modules to uninstall., while on the UI it is shown as installed and you can normally unsintall it from there.

Unfortunately the problem is not only that but it has implications when you try to enable the (apparently non-required) commerce_checkout, because it will fail with the same error.

The error and your services.yml reference commerce_shipping, but that's not a declared module dependency.
If you try to install it, you get again the fail by drush:
In DecoratorServicePass.php line 91:
The service "commerce_currencies.safe_promotion_order_processor" has a dependency on a non-existent service "commerce_promotion.promotion_order_processor".
Failed to run drush en commerce_shipping: exit status 1
but everything seems fine on the UI instead.

Then I try to install the cited commerce_promotion and get The service "commerce_currencies.safe_payment_order_processor" has a dependency on a non-existent service "commerce_payment.order_processor". again.. Where is this going? 😅

I think we need some documentation on how to install on a fresh site.
Also, is this module usable (meaning can a store be paid with different currencies) without shipping, ie. for digital goods?

Tested with Drupal 10.3.1

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇹Italy kopeboy Milan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kopeboy
  • 🇭🇺Hungary djg_tram

    That's true and a good catch, I created it on a site where shipping was present and I never actually realized that this is an extra dependency. We have to look into how we can make it optional. Actually, none of processors mentioned there is essential. If you look into the code, they're purely there to put their calls inside a try-catch block. The stock Commerce merely throws a `CurrencyMismatchException`, resulting in a WSOD, if the cart has items in more than one currency, I only wanted to avoid that and show a regular, user friendly error message instead of the WSOD. So, in your particular case, you should be able to simply comment out `commerce_currencies.safe_early_order_processor` and `commerce_currencies.safe_late_order_processor` without any further issue.

    I never decorated an existing class conditionally. Now that I googled for it, maybe https://www.drupal.org/docs/drupal-apis/services-and-dependency-injectio... would be the solution?

  • 🇺🇸United States mrweiner

    Simpler option might be to just add additional submodules for each additional dependency. So one for each of tax, shipping, and promotions.

  • 🇭🇺Hungary djg_tram

    I don't see what benefit hook_install would provide in this case. It's really only about a single try-catch, nothing else.

  • 🇺🇸United States mrweiner

    I was assuming that you were using hook_install here. My thought was just for e.g. if somebody installed commerce_currencies, and then subsequently installed commerce_shipping, the price field on shipments might not be updated as expected. But this might be moot depending on how commerce_currencies works.

  • 🇭🇺Hungary djg_tram

    I'll try to find some time to add the conditional handling in the coming days...

Production build 0.71.5 2024