Problem/Motivation

The method \Drupal\state_machine\Plugin\Field\FieldType\StateItem::dispatchTransitionEvent() uses $workflow = $this->getWorkflow() and right after uses $workflow->findTransition().
The problem is that the method getWorkflow() can return false. In that case, we'll get a the error mentioned in the title.

Steps to reproduce

I can reproduce it in a very specific way that is not really interesting.
Just by looking to the code we can already see the problem.

Proposed resolution

Check if $workflow an instance of WorkflowInterface before using it in $workflow->findTransition().

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dxvargas created an issue. See original summary.

dxvargas’s picture

Issue summary: View changes
sourabhsisodia_’s picture

Assigned: Unassigned » sourabhsisodia_

niharika.s made their first commit to this issue’s fork.

sourabhsisodia_’s picture

@niharika.s the if conditions are not correct

sourabhsisodia_’s picture

Assigned: sourabhsisodia_ » Unassigned
Status: Active » Needs review
divyansh.gupta’s picture

Status: Needs review » Reviewed & tested by the community

The fix addresses the issue where $workflow could be false, leading to an error when calling $workflow->findTransition(). By ensuring $workflow is an instance of WorkflowInterface before using it, the code now handles cases where the workflow is invalid. This solution should resolve the issue.Thus Moving this to RTBC.

jsacksick made their first commit to this issue’s fork.

  • jsacksick committed 74e08827 on 8.x-1.x authored by niharika.s
    Issue #3498096 by sourabhsisodia_, niharika.s, jsacksick, dxvargas,...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.