Hello,
I'm working to develop a notification system when new content is created on a site to trigger an internal review process. Unfortunately, I've been getting errors from a basic rule configuration that has me scratching my head. I was wondering if someone could take a look and see if I got some of the configurations wrong or perhaps even missing something. I'll continue to look through the issue cue in the hope of finding something that relates, but I've already applied the patch here: https://www.drupal.org/project/rules/issues/2768737. It worked to fix the dominate error message I was getting, allowing me to finally save without getting a website error. While it's good to have that fixed, the current error I'm receiving is as follows:
Argument 1 passed to Drupal\rules\Plugin\Condition\NodeIsOfType::doEvaluate() must implement interface Drupal\node\NodeInterface, string given
That it says "string given" is what suggests the problem is in my configuration. Lastly, at present, it's not a practical solution for me to use the dev branch on our live site unless I know that it's going to be pushed up from dev to production sooner than later. If I can find a solution that will not require the dev branch, that would be much better.
Thank you for any assistance - I'll post the configuration I have at present below:
uuid: 925386d1-b00f-4c60-bf0b-f82dd8094151
langcode: en
status: true
dependencies: { }
id: new_blog
label: 'New Blog'
events:
-
event_name: 'rules_entity_insert:node'
description: ''
tags:
- ''
config_version: '3'
expression:
id: rules_rule
uuid: b0114bad-7741-4a8f-8211-028f1e50a732
conditions:
id: rules_and
uuid: 1743c0cc-372d-4709-a713-6b4ef56219e5
conditions:
-
id: rules_condition
uuid: 6ce26e78-a5a6-4afc-8a8e-477d72cf6a4c
context_values:
node: node
types:
- blog
context_mapping: { }
context_processors:
node:
rules_tokens: { }
types:
rules_tokens: { }
provides_mapping: { }
condition_id: rules_node_is_of_type
negate: false
actions:
id: rules_action_set
uuid: 6e947724-c4a5-4827-9e2f-f66d02686808
actions:
-
id: rules_action
uuid: 4131ec82-690b-4de1-b8a2-1648b5a7c35b
context_values:
message: 'New BLOG'
type: Warning
repeat: true
context_mapping: { }
context_processors:
message:
rules_tokens: { }
type:
rules_tokens: { }
repeat:
rules_tokens: { }
provides_mapping: { }
action_id: rules_system_message
Comments
Comment #2
tr commentedThe problem is that in your condition, you need to use the Data selector mode to enter "node" as the first context parameter. From your export, it looks like you typed that in direct input mode. Direct input passes a string value, while the data selector passes a typed data object. This is why you get that error about the condition receiving a string instead of a NodeInterface.
It seems that the UI defaults to using the direct input mode for this parameter, which is why I guess a lot of people encounter this problem. We should probably try to force that to be a data selector mode by default.
Here's your Rule after I made that fix. I tested it and it works. Note I also changed the type of message from "Warning" to "warning", since what is needed here is the machine name of the message type, not the human-readable label. When the UI is finished, this will be a select box with the available choices, but for now you have to enter the 'key' of the selection instead of the 'value'. That's true throughout the UI, not just for this one parameter.
Comment #3
jess_m commentedThank you for the help, it's appreciated. It worked once I walked myself through the steps. Should be easy to replicate with the other content types I need to use it on too.
Cheers!
Jess
Comment #4
tr commentedComment #6
tr commented