Deprecated function: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\commerce_currency_resolver\Resolver\CommerceCurrencyResolver->resolve() (line 101

Created on 9 May 2023, over 1 year ago
Updated 17 May 2023, over 1 year ago

Problem/Motivation

I used the module to convert currencies, I encountered the following error with Drupal 10.0.9:

TypeError: Drupal\commerce_exchanger\AbstractExchangerCalculator::priceConversion(): Argument #2 ($target_currency) must be of type string, null given, called in /www/wwwroot/myweb/modules/contrib/commerce_currency_resolver/src/Resolver/CommerceCurrencyResolver.php on line 112 in Drupal\commerce_exchanger\AbstractExchangerCalculator->priceConversion() (line 65 of /www/wwwroot/myweb/modules/contrib/commerce_exchanger/src/AbstractExchangerCalculator.php).

Steps to reproduce

I defined a Price Type field in Product variation. I works well in the past few days. I encountered the error today. I cannot always reproduce this error, but I encountered this error in several installations.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: works as designed

Version

1.61

Component

Code

Created by

🇨🇳China hongqing

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

Comments & Activities

  • Issue created by @hongqing
  • 🇨🇳China hongqing

    Encountered the error again and the report has more information.

    Deprecated function: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\commerce_currency_resolver\Resolver\CommerceCurrencyResolver->resolve() (line 101 of /www/wwwroot/myweb/modules/contrib/commerce_currency_resolver/src/Resolver/CommerceCurrencyResolver.php) 
    #0 /www/wwwroot/myweb/core/includes/bootstrap.inc(158): _drupal_error_handler_real()
    #1 [internal function]: _drupal_error_handler()
    #2 /www/wwwroot/myweb/modules/contrib/commerce_currency_resolver/src/Resolver/CommerceCurrencyResolver.php(101): strtolower()
    #3 /www/wwwroot/myweb/modules/contrib/commerce/modules/price/src/Resolver/ChainPriceResolver.php(49): Drupal\commerce_currency_resolver\Resolver\CommerceCurrencyResolver->resolve()
    #4 /www/wwwroot/myweb/modules/contrib/commerce/modules/order/src/PriceCalculator.php(106): Drupal\commerce_price\Resolver\ChainPriceResolver->resolve()
    #5 /www/wwwroot/myweb/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php(171): Drupal\commerce_order\PriceCalculator->calculate()
    #6 /www/wwwroot/myweb/core/lib/Drupal/Core/Field/FormatterBase.php(89): Drupal\commerce_order\Plugin\Field\FieldFormatter\PriceCalculatedFormatter->viewElements()
    #7 /www/wwwroot/myweb/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(265): Drupal\Core\Field\FormatterBase->view()
    #8 /www/wwwroot/myweb/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(339): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple()
    #9 /www/wwwroot/myweb/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(281): Drupal\Core\Entity\EntityViewBuilder->buildComponents()
    #10 /www/wwwroot/myweb/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(238): Drupal\Core\Entity\EntityViewBuilder->buildMultiple()
    #11 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build()
    #12 /www/wwwroot/myweb/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
    #13 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
    #14 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
    #15 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #16 /www/wwwroot/myweb/core/lib/Drupal/Core/Template/TwigExtension.php(477): Drupal\Core\Render\Renderer->render()
    #17 /www/wwwroot/myweb/sites/default/files/php/twig/645bfc4e1b80d_field.html.twig_FT-k8xbvR2ajoh_gP42oEizl-/hwILbJyq0DS0jKfIk3qE98T9QNrvYJslSUOOeEa2pqY.php(68): Drupal\Core\Template\TwigExtension->escapeFilter()
    #18 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(394): __TwigTemplate_883fc710d1c808415b290870817d143e->doDisplay()
    #19 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
    #20 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
    #21 /www/wwwroot/myweb/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render()
    #22 /www/wwwroot/myweb/core/themes/engines/twig/twig.engine(53): Twig\TemplateWrapper->render()
    #23 /www/wwwroot/myweb/core/lib/Drupal/Core/Theme/ThemeManager.php(372): twig_render_template()
    #24 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #25 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #26 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #27 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #28 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #29 /www/wwwroot/myweb/core/lib/Drupal/Core/Template/TwigExtension.php(477): Drupal\Core\Render\Renderer->render()
    #30 /www/wwwroot/myweb/sites/default/files/php/twig/645bfc4e1b80d_commerce-product.html.twi_NNI0iGwpIgeDSyLjF1ZOaHZVq/YpDiCXi03JEx4goU51Q33biuAgvW4aghVwGAmeCzFcs.php(50): Drupal\Core\Template\TwigExtension->escapeFilter()
    #31 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(394): __TwigTemplate_ea47ffd63e92996f51b7fb1d1be1e85c->doDisplay()
    #32 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
    #33 /www/wwwroot/myweb/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
    #34 /www/wwwroot/myweb/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render()
    #35 /www/wwwroot/myweb/core/themes/engines/twig/twig.engine(53): Twig\TemplateWrapper->render()
    #36 /www/wwwroot/myweb/core/lib/Drupal/Core/Theme/ThemeManager.php(372): twig_render_template()
    #37 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #38 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #39 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render()
    #40 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #41 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext()
    #42 /www/wwwroot/myweb/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare()
    #43 /www/wwwroot/myweb/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
    #44 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    #45 /www/wwwroot/myweb/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
    #46 /www/wwwroot/myweb/vendor/symfony/http-kernel/HttpKernel.php(168): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #47 /www/wwwroot/myweb/vendor/symfony/http-kernel/HttpKernel.php(74): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #48 /www/wwwroot/myweb/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #49 /www/wwwroot/myweb/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #50 /www/wwwroot/myweb/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #51 /www/wwwroot/myweb/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
    #52 /www/wwwroot/myweb/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
    #53 /www/wwwroot/myweb/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #54 /www/wwwroot/myweb/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #55 /www/wwwroot/myweb/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #56 /www/wwwroot/myweb/core/lib/Drupal/Core/DrupalKernel.php(686): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #57 /www/wwwroot/myweb/index.php(19): Drupal\Core\DrupalKernel->handle()
    #58 {main}
    
    
    
  • Status changed to Closed: works as designed over 1 year ago
  • 🇨🇳China hongqing

    Finally, I find this error is because no store is created.

Production build 0.71.5 2024