Referenced entities don't correctly find the Node context

Created on 16 January 2025, 3 months ago

Problem/Motivation

Using this module's WorkflowFieldValue condition plugin in a project where we have entities that are referenced by Nodes, that need to determine if the "parent" node is in a given workflow state. In this context, the getEntity() routine that relies on the "entity:node" context fails, and the Condition never applies correctly, because the relevant node object isn't found.

Steps to reproduce

1. Create a node type A with a workflow field and some states.
2. Create a node type B with at least one field, to which you will grant/deny access based on workflow state.
3. On node type A, create an entityreference field "field_B" that references a "B" node.
4. Create a B node and an A node that references it. Set it in a particular workflow state.
5. Create an ECA model using the "Determine entity field access", and configure the Entity Type ID to be "node", Restrict by entity bundle "B", Restrict by operation "edit", and Restrict by field_name "field_B"
6. Create a Condition in the model, using WorkflowFieldValue, and configure it per usual, selecting an Expected Workflow state value (use the same one as above), and "node" as the entity token.
7. Create an Action to deny access, and set it to be a successor to the model's Event, using the WorkflowFieldValue Condition to check first.
7. Edit the A node, and see that you are *not* denied access to the field_B in the form.

Proposed resolution

Adjust the getEntity() routine in the plugin so that it uses the node_route context in lieu of relying on the entity:node context. This means it will only apply when actually on the node page in question, but I think we can arrange it so we look for the "default" context value for the node first, and fall back to the route-based one if that fails.

Remaining tasks

Prepare a patch.

User interface changes

None.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada spiderman Halifax, NS

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024