Function getWorkflowType doesn't check $workflow before usage

Created on 1 June 2023, over 1 year ago
Updated 5 June 2023, over 1 year ago

Problem/Motivation

In the function getWorkflowType the $workflow can be NULL thus it should be checked before usage.

Steps to reproduce

This issue came up in our pipeline, backtrace

 [error]  Error: Call to a member function getTypePlugin() on null in Drupal\webform_workflows_element\Service\WebformWorkflowsManager->getWorkflowType() (line 80 of modules/contrib/webform_workflows_element/src/Service/WebformWorkflowsManager.php) #0 modules/contrib/webform_workflows_element/src/Service/WebformWorkflowsManager.php(65): Drupal\webform_workflows_element\Service\WebformWorkflowsManager->getWorkflowType('css_form_flow')
#1 modules/contrib/webform_workflows_element/src/Service/WebformWorkflowsManager.php(125): Drupal\webform_workflows_element\Service\WebformWorkflowsManager->getWorkflowTypeFromElement(Array)
#2 modules/contrib/webform_workflows_element/src/Element/WebformWorkflowsElement.php(38): Drupal\webform_workflows_element\Service\WebformWorkflowsManager->getInitialStateForElement(Array)
#3 modules/contrib/webform/src/Element/WebformCompositeBase.php(209): Drupal\webform_workflows_element\Element\WebformWorkflowsElement::getCompositeElements(Array)
#4 modules/contrib/webform/src/Plugin/WebformElement/WebformCompositeBase.php(1276): Drupal\webform\Element\WebformCompositeBase::initializeCompositeElements(Array)
#5 modules/contrib/webform/src/Plugin/WebformElement/WebformCompositeBase.php(166): Drupal\webform\Plugin\WebformElement\WebformCompositeBase->initializeCompositeElements(Array)

Proposed resolution

Check $workflow before usage.

Remaining tasks

Write patch.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇮Finland MikaT

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

Comments & Activities

Production build 0.71.5 2024