Constructing JsonApiClient before setting module config leads to fatal.

Created on 1 January 2023, almost 2 years ago
Updated 15 January 2023, almost 2 years ago

Problem/Motivation

A fatal error occurs if trying to construct the JsonApiClient if it has no config set.

Steps to reproduce

Install the module and attempt to add a field of type TypedReferenceObject before adding any configuration.

A page showing 'The website encountered an unexpected error. Please try again later.' will be displayed.

Logs show TypeError: Cannot assign null to property Drupal\jsonapi_reference\JsonApiClient::$entrypoint of type string in /var/www/html/web/modules/contrib/jsonapi_reference/src/JsonApiClient.php on line 47 #0 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(263): Drupal\jsonapi_reference\JsonApiClient->__construct(Object(GuzzleHttp\Client), Object(Drupal\Core\Logger\LoggerChannel), Object(Drupal\Core\Config\ConfigFactory))

Proposed resolution

Check the results from config factory for all jsonapi_reference settings, converting to empty strings in the constructor if NULL.

Remaining tasks

All the things.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom Eli-T Manchester

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024