Fatal error: Views field handlers should check transition is not null

Created on 3 September 2023, over 1 year ago
Updated 5 September 2023, over 1 year ago

Problem/Motivation

It should be possible to make generic use of the provided views field handlers ScheduledTransitionRevisionLinkField, ScheduledTransitionToStateViewsField and ScheduledTransitionFromStateViewsField fvia appropriate relationships. But if any of the revisions in the view does not have a scheduled transition, a fatal php error occurs:

Error: Call to a member function getWorkflow() on null in Drupal\scheduled_transitions\Plugin\views\field\ScheduledTransitionToStateViewsField->render() (line 28 of /var/www/html/public/modules/contrib/scheduled_transitions/src/Plugin/views/field/ScheduledTransitionToStateViewsField.php).

The field handler is blindly assuming it will only be used on revisions that have a scheduled transition, ie only in the provided scheduled transitions view.

Steps to reproduce

  1. Add chained vid and scheduled_transition relationships to a view of entity revisions.
  2. Add a scheduled transition: New State field to the view using that relationship.
  3. Save a new revision, do not schedule it. The above exception is thrown.

Proposed resolution

Check that the transition is not null in each field handler.

🐛 Bug report
Status

Needs work

Version

2.4

Component

Code

Created by

🇳🇿New Zealand john pitcairn

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

Comments & Activities

Production build 0.71.5 2024