Call to a member function toArray() on null

Created on 26 April 2023, about 2 years ago

Problem/Motivation

/Error/: Call to a member function toArray() on null in /Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateDailyRangeFormatter->viewElements()/ (line /101/ of [webroot]/web/modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateDailyRangeFormatter.php/)

We are getting a WSOD on view pages which display certain nodes. We believe it might be due to other issues which we are having a hard time tracking down but it feels like these lines should have a check to see that the load is successful. Unless this is impossible that the load would fail?

Steps to reproduce

Unfortunately we can't seem to replicate as it seems to be a different issue which may not be to do with Smart date.
We are also using 3.6.1 currently as we can't update yet but the file itself is the same on 3.7.2 so I believe it would be the same issue.

Proposed resolution

Without a better understanding of the Smart date module I wouldn't want to code the check myself but I feel like we should have a check between these lines.

$rrule_obj = SmartDateRule::load($item->rrule);
$rule_props = $rrule_obj->toArray();
🐛 Bug report
Status

Fixed

Version

4.0

Component

Smart Date Recur

Created by

🇦🇺Australia tisteegz

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

Comments & Activities

Production build 0.71.5 2024