Problem/Motivation
It appears that in a disconnected state, the salesforce.soap_client service can prevent update.php from running. To reproduce:
1. Enable the salesforce_soap module.
2. Disconnect your site from Salesforce (admin/config/salesforce/revoke).
3. Run drush updb
4. See error:
In SoapClient.php line 80:
Salesforce needs to be authorized to connect to this website.
It appears that the salesforce.soap_client service is initialized when update.php is run. It looks like a connection to the SOAP API is attempted in the constructor for the salesforce.soap_client service's class, Drupal\salesforce_soap\Soap\SoapClient. As part of that connection attempt, a check is done to see if the site is authorized to communicate with Salesforce. When that check comes back false, this initial connection attempt throws \Exception('Salesforce needs to be authorized to connect to this website.').
Proposed resolution
We could simply remove the initial connection attempt from the constructor, since Drupal\salesforce_soap\Soap\SoapClient::trySoap() will attempt to connect, if necessary, prior to making any soap calls. Along with trySoap(), we also have the connect() and isConnected() methods for folks who choose to execute calls without the help of trySoap(), which I'd imagine folks in that camp (if any) would already be using.
I like this approach because it's simple and follows what we see in Drupal\salesforce\Rest\RestClient, where it appears a connection to Salesforce is not attempted directly in the constructor.
Remaining tasks
- Patch
- Review
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | salesforce-soap-brick-bug-3030592-4.patch | 816 bytes | chrisolof |
Comments
Comment #2
chrisolofComment #3
aaronbaumanYup, eliminate network connections during bootstrap
Comment #4
chrisolofPatch attached.
Comment #5
chrisolofComment #7
aaronbaumanThanks for the patch!