TypeError: Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin::__construct(): Argument #4 ($httpClient) must be of type OAuth\Common\Http\Client\ClientInterface, GuzzleHttp\Client given

Created on 14 March 2024, 9 months ago
Updated 5 June 2024, 7 months ago

Problem/Motivation

After upgrading to 5.0.4, I got an error when running when running "drush updatedb". I patched around that, but then when I take my patch out, I get that error when going to various Salesforce module pages.

Steps to reproduce

When I go to /admin/config/salesforce/authorize, I get this error:
TypeError: Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin::__construct(): Argument #4 ($httpClient) must be of type OAuth\Common\Http\Client\ClientInterface, GuzzleHttp\Client given, called in /var/www/suds.clfoundation.org/web/modules/contrib/salesforce/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php on line 61 in Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin->__construct() (line 44 of /var/www/suds.clfoundation.org/web/modules/contrib/salesforce/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php).
Here's the full stack trace:

#0 web/modules/contrib/salesforce/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php(61): Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin->__construct()
#1 web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin::create()
#2 web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(76): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance()
#3 web/modules/contrib/salesforce/src/Entity/SalesforceAuthConfig.php(106): Drupal\Component\Plugin\PluginManagerBase->createInstance()
#4 web/modules/contrib/salesforce/src/Form/SalesforceAuthSettings.php(85): Drupal\salesforce\Entity\SalesforceAuthConfig->getPlugin()
#5 [internal function]: Drupal\salesforce\Form\SalesforceAuthSettings->buildForm()
#6 web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#7 web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm()
#8 web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#9 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#10 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#11 web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#13 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#14 vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#16 web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#17 web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#18 web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#19 web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle()
#20 web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#21 web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#22 web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#23 web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#24 web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#25 web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#26 web/index.php(19): Drupal\Core\DrupalKernel->handle()
#27 {main}

Proposed resolution

Here's the patch I used to get around the error.

diff --git a/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php b/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php
index 3fa0a9e73..960c2daf6 100644
--- a/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php
+++ b/modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php
@@ -55,7 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio
       $configuration,
       $plugin_id,
       $plugin_definition,
-      $container->get('http_client'),
+      $container->get('salesforce.http_client_wrapper'),
       $container->get('salesforce.auth_token_storage'),
       $container->get('config.factory'),
       $container->get('tempstore.private')

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

5.0

Component

salesforce_oauth.module

Created by

🇺🇸United States Peter Haight

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

Comments & Activities

Production build 0.71.5 2024