Set a data value action fails in Drupal 10

Created on 29 November 2023, 9 months ago
Updated 30 November 2023, 9 months ago

Problem/Motivation

Trying to set a field value after saving (or before).

Steps to reproduce

Import this test rule

uuid: 1773974c-4515-4efa-84ce-97ccbecfa198
langcode: en
status: false
dependencies: {  }
id: test1
label: test1
events:
  -
    event_name: 'rules_entity_update:node--page'
description: ''
tags: {  }
config_version: '3'
expression:
  id: rules_rule
  uuid: f87f1be1-87e4-4afa-a1bc-319c4d00ed9d
  weight: 0
  conditions:
    id: rules_and
    uuid: 2dad0d04-a038-4a52-aa8d-4a8748574ee1
    weight: 0
    conditions:
      -
        id: rules_condition
        uuid: c6123b02-a589-4de1-93df-1036a743372f
        weight: 0
        condition_id: rules_entity_is_of_bundle
        negate: false
        context_values:
          type: node
          bundle: page
        context_mapping:
          entity: node
        context_processors:
          type:
            rules_tokens: {  }
          bundle:
            rules_tokens: {  }
        provides_mapping: {  }
  actions:
    id: rules_action_set
    uuid: 91e1cde3-aa98-4642-98bc-6374b0976006
    weight: 0
    actions:
      -
        id: rules_action
        uuid: 55030240-7f1e-48f8-9389-faeea73ccc21
        weight: 0
        action_id: rules_data_set
        context_values:
          value: '12345'
        context_mapping:
          data: node.title.value
        context_processors:
          value:
            rules_tokens: {  }
        provides_mapping: {  }

Then save an existing page. Site timesout. Maybe a loop is happening?

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Component

Rules Core

Created by

πŸ‡¬πŸ‡§United Kingdom mchaplin

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

Comments & Activities

  • Issue created by @mchaplin
  • πŸ‡¬πŸ‡§United Kingdom mchaplin
  • πŸ‡¬πŸ‡§United Kingdom mchaplin

    OK so it must go into some sort of loop.
    The solution is to add a condition that excludes the outcome set in the action ie I want to set the title to '12345' so I add a condition which excludes nodes where the title == '12345'.

    Here the same rule as above but with the extra condition:

    uuid: 1773974c-4515-4efa-84ce-97ccbecfa198
    langcode: en
    status: true
    dependencies: { }
    id: test1
    label: test1
    events:
    -
    event_name: 'rules_entity_update:node--page'
    description: ''
    tags: { }
    config_version: '3'
    expression:
    id: rules_rule
    uuid: f87f1be1-87e4-4afa-a1bc-319c4d00ed9d
    weight: 0
    conditions:
    id: rules_and
    uuid: 2dad0d04-a038-4a52-aa8d-4a8748574ee1
    weight: 0
    conditions:
    -
    id: rules_condition
    uuid: c6123b02-a589-4de1-93df-1036a743372f
    weight: 0
    condition_id: rules_entity_is_of_bundle
    negate: false
    context_values:
    type: node
    bundle: page
    context_mapping:
    entity: node
    context_processors:
    type:
    rules_tokens: { }
    bundle:
    rules_tokens: { }
    provides_mapping: { }
    -
    id: rules_condition
    uuid: 210bcbc4-2452-4391-9bf1-63af6057c757
    weight: 0
    condition_id: rules_data_comparison
    negate: true
    context_values:
    operation: '=='
    value: '12345'
    context_mapping:
    data: node.title.value
    context_processors:
    operation:
    rules_tokens: { }
    value:
    rules_tokens: { }
    provides_mapping: { }
    actions:
    id: rules_action_set
    uuid: 91e1cde3-aa98-4642-98bc-6374b0976006
    weight: 0
    actions:
    -
    id: rules_action
    uuid: 55030240-7f1e-48f8-9389-faeea73ccc21
    weight: 0
    action_id: rules_data_set
    context_values:
    value: '12345'
    context_mapping:
    data: node.title.value
    context_processors:
    value:
    rules_tokens: { }
    provides_mapping: { }

  • πŸ‡ΊπŸ‡ΈUnited States TR Cascadia
Production build 0.71.5 2024