Skip to content

Commit

Permalink
Merged PR 55616: Revert "No response in REST client" update
Browse files Browse the repository at this point in the history
## What's being changed

We're reverting / amending [this commit](669e9ae).

## Why it's being changed

In 4.25.2 we released a bugfix that was supposed to prevent a bad API response looking like a partial success, when connecting to a Dotdigital account. However, this change means that a number of V2 client methods that might return an empty array with a 200, (like `getContactsSuppressedSinceDate`) or a 204 No Content (like `deleteAddressBookContact`), are now dumping "No response in REST client" into the logs.

I've added an extra check into the account validation code to return false if the response is empty.

## How to review / test this change

- Go to your Dotdigital account screen in the Magento admin
- Set `$accountInfo` to null above L90 in Dotdigitalgroup\Email\Model\Apiconnector\Test
- Click to Save Config
- Confirm the account shows the expected 'Authorization has been denied' message

Related work items: #259561
  • Loading branch information
sta1r committed Jun 25, 2024
1 parent 7710129 commit 71e145b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Model/Apiconnector/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ public function execute()

if (!$response) {
$response = new stdClass();
$curlError = $this->getCurlError();
$response->message = $curlError ?: 'No response in REST client';
if ($curlError = $this->getCurlError()) {
$response->message = $curlError;
}
}

$this->responseMessage = $response->message ?? null;
Expand Down Expand Up @@ -643,11 +644,9 @@ public function setVerb($verb)
*/
public function getCurlError()
{
//if curl error
if (!empty($this->curlError)) {
//log curl error
$message = 'CURL ERROR ' . $this->curlError;
$this->helper->log($message);
$this->helper->error($message);

return $this->curlError;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/Apiconnector/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function validate(string $apiUsername, string $apiPassword)
->setApiPassword($apiPassword)
->getAccountInfo($website->getId());

if (isset($accountInfo->message)) {
if (!$accountInfo || isset($accountInfo->message)) {
return false;
}
$scope = $website->getId() > 0 ? ScopeInterface::SCOPE_WEBSITES : ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
Expand Down

0 comments on commit 71e145b

Please sign in to comment.