Problem/Motivation
Cannot save Salesforce Authorization configuration at /admin/config/salesforce/authorize/add due to PHP error:
Error: Class 'Firebase\JWT\JWT' not found in /docroot/modules/contrib/salesforce/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php on line 199 #0
Full trace at end of description.
Proposed resolution
I’ll leave that to someone with better knowledge than I. However, a developer on my team pointed out line 148 of salesforce/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php:
It’s unsetting the credentials with
unset($this->credentials);but then it calls$this->generateAssertion()afterwards, which tries to access the credentials.
Remaining tasks
(reviews needed, tests to be written or run, documentation to be written, etc.)
User interface changes
None anticipated.
API changes
None anticipated.
Data model changes
None anticipated.
Release notes snippet
Fix PHP error when saving Salesforce Authorization JWT OAuth configuration.
Full trace
php-error #25 /docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
php-error #24 /docroot/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #23 /vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #22 /docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #21 /docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #20 /docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #19 /docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #18 /docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #17 /docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
php-error #16 /vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
php-error #15 /vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
php-error #14 /docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
php-error #13 /docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
php-error #12 /docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
php-error #11 /docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
php-error #10 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
php-error #9 /docroot/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
php-error #8 /docroot/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\salesforce\Form\SalesforceAuthForm), Object(Drupal\Core\Form\FormState))
php-error #7 /docroot/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('salesforce_auth...', Array, Object(Drupal\Core\Form\FormState))
php-error #6 /docroot/core/lib/Drupal/Core/Form/FormBuilder.php(578): Drupal\Core\Form\FormValidator->validateForm('salesforce_auth...', Array, Object(Drupal\Core\Form\FormState))
php-error #5 /docroot/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'salesforce_auth...')
php-error #4 /docroot/core/lib/Drupal/Core/Form/FormValidator.php(273): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
php-error #3 /docroot/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
php-error #2 [internal function]: Drupal\salesforce\Form\SalesforceAuthForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
php-error #1 /docroot/modules/contrib/salesforce/src/Form/SalesforceAuthForm.php(133): Drupal\salesforce_jwt\Plugin\SalesforceAuthProvider\SalesforceJWTPlugin->validateConfigurationForm(Array, Object(Drupal\Core\Form\FormState))
php-error [20-Jul-2020 19:56:16 America/New_York] Error: Class 'Firebase\JWT\JWT' not found in /docroot/modules/contrib/salesforce/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php on line 199 #0 /docroot/modules/contrib/salesforce/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php(152): Drupal\salesforce_jwt\Plugin\SalesforceAuthProvider\SalesforceJWTPlugin->generateAssertion()
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3160431-9-readme-update.patch | 2.87 KB | ironsizide |
| #8 | 3160431-8-readme-update.patch | 2.87 KB | ironsizide |
Comments
Comment #2
byronveale commentedComment #3
byronveale commentedNoticed the code our developer questioned was committed only recently…
Comment #4
aaronbaumanYou're missing the 3rd-party library firebase/php-jwt, meaning the module was likely installed without using composer.
You need to add this library, as well as other 3rd party dependencies in composer.json, using composer.
The recommended installation method is `composer require drupal/salesforce`
Comment #5
bakulahluwaliaJust to add some more notes to #4:
I also faced the same problem even if I have the library present in the vendor folder.
What works for me: uninstall " Salesforce JWT Auth Provider" and re-install it.
Comment #6
dmitryl commentedI experience the same error. firebase/php-jwt and drupal/salesforce are both installed via composer. Install/uninstall didn't help.
Comment #7
byronveale commentedI'm not sure exactly what’s going on, but on the surface it looks like this may be what tripped us up:
This is in the Salesforce module’s composer.json file. Evidently “suggest” wasn’t enough, firebase needed to be explicitly “required” in our profile in order to fix this.
Hope this helps…
Comment #8
ironsizide commentedThe dependencies are suggested in the main salesforce module, but they are required in the relevant submodules (salesforce_mapping, etc.). For best results require the each submodule in use in addition to the main salesforce module with composer. That will make sure the other dependencies are loaded as needed for each submodule.
I've included a patch that updates the README with this info and updated the list of included modules. I've also updated the suggest clause in the top level composer.json to include all dependencies from the submodules and the project page. These changes are informational only and to make the install process clearer.
Comment #9
ironsizide commentedRe-rolled patch to incorporate composer.json changes
Comment #10
aaronbaumanAfter numerous issues reported around missing dependencies, I don't think we should wait for Drupal core to fix the composer sub-project-dependency issue.
Probably needs a re-roll, but let's get this in.
Comment #11
therobyouknow commentedI managed to overcome this issue by:
composer require firebase/php-jwt
run in the top of my source tree, so that it applied to the overall ("global") composer.json for my whole drupal project, i.e. the composer.json used to manage my Drupal contrib module dependencies.
I had installed Salesforce 4.x-dev for Drupal 9 as the stable (green) release did not work, as described in this issue: https://www.drupal.org/project/salesforce/issues/3177326#comment-13972549 (linked to this one)
Comment #13
aaronbaumanThis one's in. Thanks for everyone's contributions
Comment #15
fraserthompsonI'm experiencing this issue in 5.0.0-alpha2 so this patch should probably be ported to 5.x if it hasn't been already
Comment #16
kevinquillen commentedI installed this module with Composer and the same thing happened to me.
```
Error: Class "Firebase\JWT\JWT" not found in Drupal\salesforce_jwt\Plugin\SalesforceAuthProvider\SalesforceJWTPlugin->generateAssertion()
```
I had to require the package with composer myself.
Comment #17
arakwarRequiring the package manually does not seems to fix the issue in the latest version...My bad. I changed my local development stack recently and just learned how agressive APCu can be at caching unavailable classes. I had the error first, then tried to install the package with composer and APCu kept in memory that the file was not available. Rebooting PHP fixed this.