Closed (duplicate)
Project:
Rules
Version:
8.x-3.x-dev
Component:
Rules Core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2016 at 16:48 UTC
Updated:
26 Jun 2019 at 07:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
intrafusionPatch to check is_array()
Comment #3
Anonymous (not verified) commentedI tried your patch and it solved also my email problem. Thx for this patch
Comment #4
hsponner commentedThanks, #2 patch working for me (sending mail to author/sender of Contact message)
Comment #5
eanushan commentedI'm running into the same scenario with
context_mapping. The patch in #2 works for me as well. Can we mark this as RTBC?Comment #6
jonathan1055 commentedI think this might be a generic problem which is tackled in #2824348: Warnings when using token replacements in multiple string context parameters.
Comment #7
admirernepali commentedGreat, patch works. Would love to see if rules team applies the patches too.
Comment #8
intrafusionSurely, 4 approvals for a one line change can be RTBC
Comment #9
jonathan1055 commentedHi intrafusion,
Yes it may seem that this should be committed, but as I understand it, the patch in #2 is is a specific fix which is a 'sticking plaster' and does not tackle the cause of the problem. We need to test that the patch in #2824348: Warnings when using token replacements in multiple string context parameters solves this error, as that is the more likely one to get committed.
Jonathan
Comment #10
fagoExactly - the passed context does not match the requirement. So the problem is in our context mapping code allowing us to do that or not taking care of the situation. We should work on this, so it will make the band-aid unnecessary.
With #2824348: Warnings when using token replacements in multiple string context parameters being committed, it should be possible to use the token replacement now instead?
Comment #11
gsquirrelAm adding this here in case it helps anyone, i finally got an email to go to the author using twig token in direct input mode rather than using the data selector.
This is the token that worked {{ node.uid.entity.mail }}
Comment #12
tdnshah commentedHow do we apply this patch?
Comment #13
jonathan1055 commentedHi tdnshah,
Here is the Drupal page on how to apply a patch for you general information. However, the proper solution to this issue will not actually involve this patch fix.
Jonathan
Comment #14
tr commentedI just tested this by creating a send mail action in response to an event. I used one e-mail address in the to: field, on a single line. I am using the current up-to-date Rules 8.x-3.x.
I did not see this error.
@tdnshah Are you seeing this error in the current 8.x-3.x-dev release?
Comment #15
brtamas commentedFor 8.3.0-alpha4
Comment #16
tr commentedThank you, but there are a lot of problems with that patch.
The patch 'adds' many files that already exist, for example .gitignore, .travis.yml, composer.lock, README.md, rules.module, etc. I didn't check in detail, but perhaps you have added the entire rules module to this patch?
There are some changes not related to this issue, for example in composer.json.
The patch also adds some files which should NOT be added, like LICENSE.txt, which doesn't belong in the repository.
It's hard for me to tell what code is part of your fix and what code is not.
Comment #17
tr commentedThis will be addressed by #2723259: Allow single-valued data selector input to be passed as an array for 'multiple' context fields
Comment #18
jonathan1055 commentedJust for clarity, the patch in #15 should be ignored. The patch in #2 can be used if you need an immediate fix before #2723259: Allow single-valued data selector input to be passed as an array for 'multiple' context fields is completed.
Comment #19
tr commented@jonathan1055: Correct, #15 should not be used. Thanks for hiding that.
I would also suggest #2 should not be used. That patch "fixes" bad input just for the SystemSendEmail action, and doesn't do anything to avoid the same issue where it occurs elsewhere, notably in the "Node is of type" action. The patch in #2 just changes the SystemSendEmail action to accept either an array or a string. That sort of type fluidity is what we are trying hard to avoid - Rules works when we can impose strong typing on top of PHP, so that we always know what type the passed data is, that way we always know how to use it and don't need to scatter isset(), is_array() etc. everywhere throughout the code when we try to use the data.
Instead of the patch in #2, this issue can be avoided by just passing the correct data type. To quote myself from #2799569-17: Cannot use account.mail.value as Send To data selector for action SystemSendEmail (with some minor changes to make it relate to the above discussion):
I consolidated a number of issues into #2723259: Allow single-valued data selector input to be passed as an array for 'multiple' context fields because they all revolve around this same problem of assigning a single-valued variable chosen in the data selector to a context parameter that accepts only an array of values. The actions where this issue show up are different, but they all have the same cause and they all have the same solution or "workaround" described in the previous paragraph above.
Comment #20
jonathan1055 commentedThanks TR for taking the time to explain the background reasoning, that is really helpful.