Problem/Motivation
When accessing the user salesforce mapping page (/user/{uid}/salesforce) without an active Salesforce OAuth token (e.g., token revoked, expired, or not configured), the site crashes with a fatal error:
OAuth\Common\Storage\Exception\TokenNotFoundException: in
Drupal\salesforce\Storage\SalesforceAuthTokenStorage->retrieveAccessToken()
Steps to reproduce
1. Have a user with Salesforce mapped objects
2. Revoke or don't configure Salesforce OAuth token
3. Navigate to /user/{uid}/salesforce
4. Page crashes with TokenNotFoundException
Stack trace-
SalesforceAuthTokenStorage->retrieveAccessToken()
SalesforceAuthProviderPluginBase->getAccessToken()
SalesforceAuthProviderPluginBase->getInstanceUrl()
MappedObject->getSalesforceUrl()
SalesforceLinkItemList->computeValue()
MappedObjectList->buildRow()
Proposed resolution
Wrap the getSalesforceUrl() call in SalesforceLinkItemList::computeValue() with a try-catch block to gracefully handle TokenNotFoundException. When the exception is caught, display the SFID without a link instead of crashing.
| Comment | File | Size | Author |
|---|---|---|---|
| salesforce_link_item_list_token_not_found_exception.patch | 1.15 KB | hitesh-jain |
Comments
Comment #3
aaronbaumanFixed with slightly different approach