Error : Call to a member function get() on null in smart_date_recur_tokens() (/var/www/html/web/modules/contrib/smart_date/modules/smart_date_recur/smart_date_recur.tokens.inc line 125)

Created on 21 March 2023, over 1 year ago
Updated 24 April 2023, over 1 year ago

Problem/Motivation

White screen of death when displaying entity tokens via Devel module tokens tab cause by this line of code :

$rrid = $field->get('rrule')->getValue();

Because in some cases $field can be null.

Steps to reproduce

Create a custom node type with an unlimited Date range field, check the recurring checkbox.

Create an instance of the custom node type.

Install the Devel module if needed.

Click on the "Devel" tab of the created node and then on the sub tab "Tokens".

You should get a WSOD.

Proposed resolution

Just check that $field is not null before using it:

foreach($list as $field) {
if ($field === NULL) {
  continue;
}
$rrid = $field->get('rrule')->getValue();
🐛 Bug report
Status

Fixed

Version

3.7

Component

Smart Date Recur

Created by

🇫🇷France mably

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

Comments & Activities

Production build 0.71.5 2024