Error in Drupal\eloqua_api_redux\Service\EloquaApiClient->doBaseUrlRequest() when tokens not set

Created on 19 May 2023, almost 2 years ago
Updated 20 June 2023, almost 2 years ago

Problem/Motivation

If Eloqua tokens have not been saved to config, calls to Drupal\eloqua_api_redux\Service\EloquaApiClient::doEloquaApiRequest() can result in this error:

The website encountered an unexpected error. Please try again later.
TypeError: Cannot access offset of type string on string in Drupal\eloqua_api_redux\Service\EloquaApiClient->doBaseUrlRequest() (line 310 of modules/contrib/eloqua_api_redux/src/Service/EloquaApiClient.php).
Drupal\eloqua_api_redux\Service\EloquaApiClient->doBaseUrlRequest() (Line: 263)
Drupal\eloqua_api_redux\Service\EloquaApiClient->getBaseUrl() (Line: 392)
Drupal\eloqua_api_redux\Service\EloquaApiClient->doEloquaApiRequest('GET', '/api/REST/2.0/assets/form/XXXX', NULL, Array) (Line: 128)
Drupal\eloqua_api_redux\Service\Forms->getForm(XXXX, Array) (Line: 68)

Steps to reproduce

This can come up in situations such as after staging down production DB to dev or similar (or clearing token config). If a route depends on a doEloquaApiRequest call to get a contact or form, etc., the response from the Eloqua API to get the base URL is not the nested array expected. This can lead to a WSOD or PHP error displayed to screen

Proposed resolution

Handle errors from base URL request more gracefully.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024