Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am getting an error when using Rules:
Undefined index in rules_action_mail() (line 90 of mywebsite/sites/all/modules/rules/modules/system.eval.inc
The email is getting sent successfully, but this error keeps appearing as well. Any ideas on how to fix this?
Comment | File | Size | Author |
---|---|---|---|
#10 | rules_mail_lang.patch | 717 bytes | fago |
Comments
Comment #1
philipz CreditAttribution: philipz commentedI have the same problem.
I'm running Drupal Commerce and on the checkout->completion I get that error and what's worse it makes confirmation page load for more than a minute. I'm not sure if the problem is related to this slow performance but disabling the rule sending the confirmation email makes it work super fast again.
EDIT:
In my case the rule was configured improperly. I probably intalled it without locale module enabled, and then after enablig it the rule required langugage and somehow data selector for it was set to order status.
Comment #2
zdean CreditAttribution: zdean commentedI can confirm the error. My rule is set to send an email upon creation of a node. When a node is created, I get the error but the email is sent out as expected.
Comment #3
johnhoule CreditAttribution: johnhoule commentedI'm also having this issue.
Event: After saving new content
Condition: Content is sticky
Actions: Unpublish content, Send mail, Show message on site
The email does go through but the page displays the error described above.
Comment #4
rtvWebServicesLibrarian CreditAttribution: rtvWebServicesLibrarian commentedI can confirm this error as well. I have created a content type called "Event" that adds events to a site calendar.
When a new Event is created, the rule is supposed to allow the user to add one or more email addresses to send the Event information to.
Here is how my rule is constructed:
Event: after saving new content
Condition: entity has field: Parameter: Entity: [node], Field: field_email_notify
AND
Data comparison: Parameter: Data to compare: [node:field-email-notify], Data value:
Actions: Send mail: Parameter: To: [node:field-email-notify], Subject: You are invited to: "..., Message: You are cordially invited..., From: [site:current-user:mail], Language: [node:type]
Hope this helps!
Comment #5
philipz CreditAttribution: philipz commentedI guess the Language should be set to node language or manually selected language not the node:type.
Comment #6
gagoo CreditAttribution: gagoo commentedI have the same problem. thanks
Comment #7
iancm CreditAttribution: iancm commentedI'm currently experiencing this issue as well.
Comment #8
grensman CreditAttribution: grensman commentedSame problem here, anybody have an idea on this or how can i hide the error message until this is solved?
Comment #9
lily.yan CreditAttribution: lily.yan commentedI have the same problem. thanks
Comment #10
fagoDoes this patch help you?
Comment #12
fagoComment #13
luchoh CreditAttribution: luchoh commentedis changed from 2.0 to 2.1 - the fifth argument -
$langcode
is new.I managed to get rid of the error message at line 90 by opening all my mail-related rules, editing the send mail action and removing the content of the Language field. It had an irrelevant value in it anyway.
I hope this helps.
Comment #14
lily.yan CreditAttribution: lily.yan commentedThanks a lot, it works for me by removing the content of the Language field.
Comment #15
rtvWebServicesLibrarian CreditAttribution: rtvWebServicesLibrarian commentedI deleted and restored my site from an older backup, created the rule using slightly different logic, and the problem went away -- weird. Thanks so much for being out there to help!
Comment #16
luisasasi CreditAttribution: luisasasi commentedI've seen the same problem after updating to 7.23 Dates. module.
I had to revise some rules.
Example
Edit condition: Data compare
before I had node: field-to-start-pub is less than today
now I have to write node: field-to-start-pub: value is less than today
Now everything is OK
Date.module is the problem
Comment #17
fagoPlease test the patch from #10 so we know whether it fixes the problem without requiring workarounds.
Comment #18
loze CreditAttribution: loze commented#10 worked for me.
Comment #19
waverate CreditAttribution: waverate commented#10 works for me.
Comment #20
cedewey#10 worked for me as well.
Comment #21
Everett Zufelt CreditAttribution: Everett Zufelt commentedI'm not sure if it is related, but I would be surprised if it were not. Since upgrading to Rules 7.x-2.1 our mail actions (executed on Drupal Commerce Checkout Completion) are set to the data selector commerce-order:state. The rules are in their default state, and the data selector is not featurized.
Comment #22
dotist CreditAttribution: dotist commentedI was having the same problem - removing the language value fixed it for me (was not pertinent anyway).
Comment #23
Everett Zufelt CreditAttribution: Everett Zufelt commented@dotist
Agreed, saving the send mail action after removing the content from Language and re-featurizing solves the problem. Is this related to the current issu, if so should it be rolled into the same patch?
Comment #24
FranckV CreditAttribution: FranckV commentedHere is the quick fix that worked for me:
/**
* Action Implementation: Send mail.
*/
function rules_action_mail($to, $subject, $message, $from = NULL, $langcode, $settings, RulesState $state, RulesPlugin $element) {
$to = str_replace(array("\r", "\n"), '', $to);
$from = !empty($from) ? str_replace(array("\r", "\n"), '', $from) : NULL;
$params = array(
'subject' => $subject,
'message' => $message,
'langcode' => $langcode,
);
// Set a unique key for this mail.
$name = isset($element->root()->name) ? $element->root()->name : 'unnamed';
$key = 'rules_action_mail_' . $name . '_' . $element->elementId();
$languages = language_list();
$language = $langcode == LANGUAGE_NONE ? language_default() : $languages[$langcode];
$message = drupal_mail('rules', $key, $to, $language, $params, $from);
if ($message['result']) {
watchdog('rules', 'Successfully sent email to %recipient', array('%recipient' => $to));
}
}
Comment #25
winarcht CreditAttribution: winarcht commented@FranckV:
I think your code should be like this:
Comment #26
ntigh52 CreditAttribution: ntigh52 commentedwhen I try to add text in non english on the "Send an order notification e-mail" - drupal commerce, - I get the same error!
There is a solution for that?
whats wrong?
Thanks
Comment #27
ntigh52 CreditAttribution: ntigh52 commented#10: rules_mail_lang.patch queued for re-testing.
Comment #29
ntigh52 CreditAttribution: ntigh52 commentedHi all,
can I use the patch, rules_mail_lang.patch?
does this patch will solve the bug?
why the patch, rules_mail_lang.patch failed testing?
Thanks/
Comment #30
ntigh52 CreditAttribution: ntigh52 commentedhere a solution.
http://drupal.org/node/1649258#comment-617240
Comment #31
mitchell CreditAttribution: mitchell commented(14, 18, 19) confirm the fix in #10.
(21, 23-30) aren't related to the patch.
@21: Please open a separate issue and explain the context further.
Comment #32
rfay#10: rules_mail_lang.patch queued for re-testing.
Comment #33
hmartens CreditAttribution: hmartens commentedIs there anyway I can get around this until the update is officially available?
Thanks guys for the help!
Comment #34
fagoCommitted #10 , thanks.