1

I would like to show a message when content has changed moderation states from review to published. I set this up below but it does not work. Is there a rules debug log in Drupal 8?

Event: When content is update.

Condition: Data Comparison.

  • node.moderation_state
  • Operator: ==
  • data value: published

Action: Send System message, with

  • The message type
  • drupal_get_message(‘status’);

But this doesn’t work. I get this error:

error php InvalidArgumentException: Cannot set a list with a non-array value. in Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue() (line 59 of /var/www/html/d815/core/lib/Drupal/Core/TypedD

0

Part 1 - Understanding the problem

I'm not sure if you won't run into other problems in trying to get this to work in D8 (as per the current status of the Rules module for D8), but IMO the first issue you need to resolve is that "...Cannot set a list with a non-array value ..." (as contained in your error message).

It seems to me that you should use something like what in D7 is called "List contains item" as your Rules Condition. For way more details on that, refer to the answer to the (D7 related) question about "Loop through all entities with rules".

Part 2 - More info that may help to get it to work

Your issue appears to be related to the (fixed) issue (= a task, not a bug ...), from Klausi, about "Support multiple contexts in the UI" which states:

Currently we only use a simple textfield for contexts in conditions and actions. Conditions such as the UserHasRole condition have their Roles context defined as multiple, which means the user should specify more than one value in a text field. A default implementation could just display a textarea where one line is one item in the list.

The fix for this issue appears to be included in this pull request.

Disclaimer: I have not QA-reviewed this (yet) (but that's what I would go for to get it to work).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.