Language is not a required parameter

Created on 8 December 2023, over 1 year ago
Updated 2 May 2024, 11 months ago

Problem/Motivation

The doc block for pet_send_one_mail() indicates that the only parameters required in the $params array are 'pet_from' and 'pet_to' and makes no mention of a 'language' parameter. However, line 266 assumes that $params['language'] is an object. If $params['language'] is not defined or is not an object, the function fails with "Call to a member function getId() on null".

Steps to reproduce

Attempt to use pet_send_one_mail() without defining $params['language'].

Proposed resolution

Check whether $params['language'] is defined, and if not, use \Drupal::languageManager()->getCurrentLanguage() instead.

Add to the doc block for the function to indicate that 'language' is an optional parameter.

Remaining tasks

Make a fork.

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024