Problem/Motivation
Hello,
I'm not sure whether this is a bug or a config issue on my part with a rule. Here's what's happening; I have a simple rule that does some math on two fields in a bundle, then puts the result into another field. If I have the rule react "After saving a new content item entity of type Classified Ad" it works fine. If I change it to run either "After updating a content item entity of type Classified Ad" or "Before saving a content item entity of type Classified Ad" the site goes to a WSOD after the PHP timeout period.
In the first instance when it works, I get this in the log:
Rules evaluation log-Close all-
Reacting on event After saving a new content item entity.
0 ms Reacting on event After saving a new content item entity.
0.044 ms Evaluating conditions of rule Rule. [edit]
7.001 ms The condition Entity is of bundle evaluated to TRUE. [edit]
7.478 ms The condition NOT Data value is empty evaluated to TRUE. [edit]
7.56 ms Condition set (AND) evaluated to TRUE.
Rule Rule fires. [edit]
0 ms Rule Rule fires.
14.232 ms Evaluating the action Calculate a numeric value. [edit]
15.73 ms Evaluating the action Set a data value. [edit]
16.175 ms Rule Rule has fired.
23.828 ms Finished reacting on event After saving a new content item entity.
In the 2nd & 3rd instances I don't get any Rules log messages, only this:
https://mysite/admin/config/workflow/rules
Message Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: INSERT INTO "cache_discovery" ("cid", "expire", "created", "tags", "checksum", "data", "serialized") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6) ON DUPLICATE KEY UPDATE "cid" = VALUES("cid"), "expire" = VALUES("expire"), "created" = VALUES("created"), "tags" = VALUES("tags"), "checksum" = VALUES("checksum"), "data" = VALUES("data"), "serialized" = VALUES("serialized"); Array ( [:db_insert_placeholder_0] => last_write_timestamp_cache_discovery [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1653741731.784 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => d:1653741731.7850000858306884765625; [:db_insert_placeholder_6] => 1 ) in Drupal\Core\Cache\DatabaseBackend->doSetMultiple() (line 273 of /home/mysite/public_html/core/lib/Drupal/Core/Cache/DatabaseBackend.php).
Here's the config of the working rule:
uuid: 02ff2505-aab9-4e4e-ba3c-a32df440d73a
langcode: en
status: true
dependencies: { }
id: bsgc_s_cut
label: 'BSGC''s Cut'
events:
-
event_name: 'rules_entity_insert:node--classified_ad'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: c1e62ef7-5823-4aa6-a537-48a83fe15d3f
weight: 0
conditions:
id: rules_and
uuid: 6f1e2922-be8e-4428-9986-870a4845166f
weight: 0
conditions:
-
id: rules_condition
uuid: 8650db74-ce82-46c9-8b47-125ab052ac7f
weight: 0
condition_id: rules_entity_is_of_bundle
negate: false
context_values:
type: node
bundle: classified_ad
context_mapping:
entity: node
context_processors:
type:
rules_tokens: { }
bundle:
rules_tokens: { }
provides_mapping: { }
-
id: rules_condition
uuid: 8d9cd1bb-3abb-4d3c-bd87-091e767aa362
weight: 0
condition_id: rules_data_is_empty
negate: true
context_values: { }
context_mapping:
data: node.field_ad_price.value
context_processors: { }
provides_mapping: { }
actions:
id: rules_action_set
uuid: b6b8a690-7279-4563-b8ce-f96f1f10b74d
weight: 0
actions:
-
id: rules_action
uuid: 9d0880ba-156e-4157-9a53-5b6f3a60aa78
weight: 0
action_id: rules_data_calculate_value
context_values:
operator: '*'
context_mapping:
input_1: node.field_ad_price.value
input_2: node.field_multiplier.value
context_processors:
operator:
rules_tokens: { }
provides_mapping:
result: bsgc_cut_value
-
id: rules_action
uuid: 3c714d21-9dc0-4b95-b14a-7cf9408689fa
weight: 0
action_id: rules_data_set
context_values: { }
context_mapping:
data: node.field_bsgc_cut.value
value: bsgc_cut_value
context_processors: { }
provides_mapping: { }
And here's the config of the non-working rule:
uuid: 6f5af2f0-271c-413d-bfe0-57912f74528e
langcode: en
status: false
dependencies: { }
id: bsgc_cut_update
label: 'BSGC Cut Update'
events:
-
event_name: 'rules_entity_update:node--classified_ad'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: 678b7ae0-85e8-4f99-bf87-9b37047995e6
weight: 0
conditions:
id: rules_and
uuid: a1394d5a-ac0d-4c96-870d-b77804cf338c
weight: 0
conditions:
-
id: rules_condition
uuid: 52d00bc2-2a83-4938-9d1a-934d26a2fc8c
weight: 0
condition_id: rules_entity_is_of_bundle
negate: false
context_values:
type: node
bundle: classified_ad
context_mapping:
entity: node
context_processors:
type:
rules_tokens: { }
bundle:
rules_tokens: { }
provides_mapping: { }
-
id: rules_condition
uuid: c6d86e38-ae42-449c-95f8-4870f37870bf
weight: 0
condition_id: rules_data_is_empty
negate: true
context_values: { }
context_mapping:
data: node.field_ad_price.value
context_processors: { }
provides_mapping: { }
actions:
id: rules_action_set
uuid: 56bcdc87-88c3-4b62-8479-c67fb506a971
weight: 0
actions:
-
id: rules_action
uuid: 92860153-430d-4544-9095-3c24828708f7
weight: 0
action_id: rules_data_calculate_value
context_values:
operator: '*'
context_mapping:
input_1: node.field_ad_price.value
input_2: node.field_multiplier.value
context_processors:
operator:
rules_tokens: { }
provides_mapping:
result: result_1
-
id: rules_action
uuid: 75bf9764-39b4-414e-ad46-d8dfd05dcc94
weight: 0
action_id: rules_data_set
context_values: { }
context_mapping:
data: node.field_bsgc_cut.value
value: result_1
context_processors: { }
provides_mapping: { }
The two rules are identical except for when they fire. Is there something I've done wrong, a bug, or some other issue? Any help would be greatly appreciated.
Thanks!
-=Delty