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.

Comments

chrisolof created an issue. See original summary.

chrisolof’s picture

Title: Disconnected SOAP client service can interfere stop update.php from running » Disconnected SOAP client service can stop update.php from running
aaronbauman’s picture

We could simply remove the initial connection attempt from the constructor

Yup, eliminate network connections during bootstrap

chrisolof’s picture

Status: Active » Needs review
StatusFileSize
new816 bytes

Patch attached.

chrisolof’s picture

Issue summary: View changes

aaronbauman’s picture

Status: Needs review » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.