Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Describe your bug or feature request.
I've been investigating some of the D9 test failures today (See https://www.drupal.org/pift-ci-job/2140511), and investigated the following error message:
Error: Call to a member function id() on null
/var/www/html/modules/contrib/commerce/modules/cart/src/CartProvider.php:82
It appears this is due to the current store service being accessed really early (before a store actually gets created in our tests).
See the following backtrace to understand what's going on:
modules/contrib/commerce/modules/store/src/CurrentStore.php:65
modules/contrib/commerce/modules/store/src/Resolver/StoreCountryResolver.php:43
modules/contrib/commerce/src/Resolver/ChainCountryResolver.php:46
modules/contrib/commerce/src/CurrentCountry.php:62
modules/contrib/commerce/src/Resolver/DefaultLocaleResolver.php:54
modules/contrib/commerce/src/Resolver/ChainLocaleResolver.php:46
modules/contrib/commerce/src/CurrentLocale.php:62
modules/contrib/commerce/modules/price/src/CurrencyFormatter.php:29
core/lib/Drupal/Component/DependencyInjection/Container.php:262
core/lib/Drupal/Component/DependencyInjection/Container.php:176
modules/contrib/commerce/modules/price/src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php:72
core/lib/Drupal/Core/Field/FormatterPluginManager.php:64
core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php:81
core/lib/Drupal/Component/Plugin/LazyPluginCollection.php:80
core/lib/Drupal/Component/Plugin/LazyPluginCollection.php:148
core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php:114
core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:293
core/lib/Drupal/Core/Entity/EntityDisplayBase.php:259
core/lib/Drupal/Core/Entity/EntityStorageBase.php:494
core/lib/Drupal/Core/Entity/EntityStorageBase.php:449
core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:252
core/lib/Drupal/Core/Entity/EntityBase.php:339
core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:592
core/lib/Drupal/Core/Config/ConfigInstaller.php:373
core/lib/Drupal/Core/Config/ConfigInstaller.php:137
core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php:75
core/lib/Drupal/Core/Extension/ModuleInstaller.php:305
core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:470
core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:70
core/tests/Drupal/Tests/BrowserTestBase.php:562
core/tests/Drupal/Tests/BrowserTestBase.php:381
modules/contrib/commerce/tests/src/FunctionalJavascript/CommerceWebDriverTestBase.php:72
modules/contrib/commerce/modules/order/tests/src/FunctionalJavascript/OrderWebDriverTestBase.php:46
modules/contrib/commerce/modules/cart/tests/src/FunctionalJavascript/CartWebDriverTestBase.php:57
modules/contrib/commerce/modules/cart/tests/src/FunctionalJavascript/AddToCartMultilingualTest.php:61
I don't really understand why this isn't a problem with d8 tests though...
Calling $this->rebuildContainer();
in CommerceWebDriverTestBase::setup()
seems to fix the issue, but I wonder if we should fix this differently.
Comment | File | Size | Author |
---|---|---|---|
#5 | 3227375-5.patch | 882 bytes | jsacksick |
Comments
Comment #2
jsacksick CreditAttribution: jsacksick at Centarro commentedComment #3
jsacksick CreditAttribution: jsacksick at Centarro commentedComment #5
jsacksick CreditAttribution: jsacksick at Centarro commentedAnother approach, which skips calling the current store by passing the store to the cart provider.
Comment #6
jsacksick CreditAttribution: jsacksick at Centarro commentedThis removes 6 test failures, committing.
Comment #7
jsacksick CreditAttribution: jsacksick at Centarro commentedNot yet committed, cannot push to d.org atm.
Comment #9
jsacksick CreditAttribution: jsacksick at Centarro commented