Deprecated function: strstr()

Created on 7 November 2022, about 2 years ago
Updated 22 August 2024, 3 months ago

Problem

On order checkout "Review" page the deprecated function error appears as,

Deprecated function: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\OnsiteBase->getPaymentMethodCustomerId() (line 322 of modules\contrib\commerce_authnet\src\Plugin\Commerce\PaymentGateway\OnsiteBase.php).

Steps to reproduce

  • Add products to cart and click checkout.
  • Update "Shipping information" and select "Shipping method".
  • Update "Payment method" in "Payment information" and continue to review.
  • You should notice the following deprecation error:
    Deprecated function: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\OnsiteBase->getPaymentMethodCustomerId() (line 322 of modules\contrib\commerce_authnet\src\Plugin\Commerce\PaymentGateway\OnsiteBase.php).
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\OnsiteBase->getPaymentMethodCustomerId(Object) (Line: 457)
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AcceptJsBase->doCreatePaymentMethod(Object, Array) (Line: 361)
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AcceptJsBase->createPaymentMethod(Object, Array) (Line: 83)
    Drupal\commerce_payment\PluginForm\PaymentMethodAddForm->submitConfigurationForm(Array, Object) (Line: 169)
    Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->submitInlineForm(Array, Object) (Line: 159)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::runSubmit(Array, Object)
    call_user_func_array(Array, Array) (Line: 141)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 134)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 134)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 86)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::executeElementSubmitHandlers(Array, Object)
    call_user_func_array(Array, Array) (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'commerce_checkout_flow_multistep_default') (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm('commerce_checkout_flow_multistep_default', Array, Object) (Line: 588)
    Drupal\Core\Form\FormBuilder->processForm('commerce_checkout_flow_multistep_default', Array, Object) (Line: 320)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 219)
    Drupal\Core\Form\FormBuilder->getForm(Object, 'order_information') (Line: 143)
    Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
🐛 Bug report
Status

Fixed

Version

1.7

Component

Code

Created by

🇮🇳India vipin.j

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇷Costa Rica estebanvalerio.h

    Confirming that using the patch `commerce_authnet-deprecated-function-strstr-3319388-2.patch` fixes the issue

    I was getting the error on `/checkout/39118/review` page

    Deprecated function: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\OnsiteBase->getPaymentMethodCustomerId() (line 322 of modules/contrib/commerce_authnet/src/Plugin/Commerce/PaymentGateway/OnsiteBase.php).
    
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\OnsiteBase->getPaymentMethodCustomerId(Object) (Line: 682)
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AcceptJs->doCreatePaymentMethod(Object, Array) (Line: 585)
    Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AcceptJs->createPaymentMethod(Object, Array) (Line: 83)
    Drupal\commerce_payment\PluginForm\PaymentMethodAddForm->submitConfigurationForm(Array, Object) (Line: 169)
    Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->submitInlineForm(Array, Object) (Line: 159)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::runSubmit(Array, Object)
    call_user_func_array(Array, Array) (Line: 141)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 134)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 134)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 86)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::executeElementSubmitHandlers(Array, Object)
    call_user_func_array(Array, Array) (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'commerce_checkout_flow_multistep_default') (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm('commerce_checkout_flow_multistep_default', Array, Object) (Line: 593)
    Drupal\Core\Form\FormBuilder->processForm('commerce_checkout_flow_multistep_default', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 224)
    Drupal\Core\Form\FormBuilder->getForm(Object, 'order_information') (Line: 143)
    Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • Status changed to RTBC 11 months ago
  • 🇺🇸United States ericchew

    I started running into this issue on my site when testing going from php 8.0 to 8.1 to prepare for D10. The patch fixes the issue for me too.

  • First commit to issue fork.
  • Pipeline finished with Success
    7 months ago
    Total: 246s
    #156890
  • 🇺🇸United States rishi kulshreshtha

    Encountered the same issue at checkout, the patch worked as expected.

  • Status changed to Fixed 4 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024