Warning: Undefined array key "#access" in hook_form_workflow_transition_form_alter()

Created on 22 November 2023, 7 months ago
Updated 15 February 2024, 4 months ago

Problem/Motivation

When accessing the node workflow tab I get the error

Warning: Undefined array key "#access" in hook_form_workflow_transition_form_alter() (line 344 of modules/contrib/workflow/workflow.api.php).
hook_form_workflow_transition_form_alter(Array, Object, 'workflow-transition-node-571-field-ad-password-state-form--2') (Line: 107)
workflow_devel_form_workflow_transition_form_alter(Array, Object, 'workflow-transition-node-571-field-ad-password-state-form--2') (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'workflow-transition-node-571-field-ad-password-state-form--2') (Line: 840)
Drupal\Core\Form\FormBuilder->prepareForm('workflow-transition-node-571-field-ad-password-state-form--2', Array, Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add', Array) (Line: 367)
Drupal\workflow\Entity\WorkflowManager::getWorkflowTransitionForm(Object, 'field_ad_password_state', Array) (Line: 105)
Drupal\workflow\Controller\WorkflowTransitionListController->historyOverview(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Create node with 1 workflow state (creation + submitted). Create a node and access the workflow tab.

Proposed resolution

Changing the workflow.api.php

Before

$workflow_element['workflow_scheduling']['#access'] = FALSE;
    // Let's prohibit scheduling for user 1.
    if (isset($element['comment']) && isset($element['comment']['#access']) && $workflow_element['comment']['#access'] == TRUE) {
      $workflow_element['comment']['#required'] = TRUE;
    }

After

if (isset($workflow_element['workflow_scheduling'])) {
      $workflow_element['workflow_scheduling']['#access'] = FALSE;
    }
    // Let's prohibit scheduling for user 1.
    if (isset($element['comment']) && isset($element['comment']['#access']) && $workflow_element['comment']['#access'] == TRUE) {
      $workflow_element['comment']['#required'] = TRUE;
    }

Remaining tasks

Testing and creating a commit (sorry i have not done this before)

🐛 Bug report
Status

Fixed

Version

1.7

Component

Code

Created by

🇩🇪Germany fox_01

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024