Fix Recoverable fatal error: Object of class stdClass could not be converted to string in _variable_store_load()

my proposal
// Fix SmtpMailSystem::mailWithoutQueue(...) with i18n_variable_get(...)

diff --git a/sites/all/modules/contrib/smtp/smtp.mail.inc b/sites/all/modules/contrib/smtp/smtp.mail.inc
index d4d0ba4..fb2ee3d 100644
--- a/sites/all/modules/contrib/smtp/smtp.mail.inc
+++ b/sites/all/modules/contrib/smtp/smtp.mail.inc
@@ -81,15 +81,17 @@ class SmtpMailSystem implements MailSystemInterface {
     // of the email being sent.
     $from_name = FALSE;
     if (function_exists('i18n_variable_get')) {
-      if (i18n_variable_get('smtp_fromname', $message['language'], '') != '') {
-        $from_name = i18n_variable_get('smtp_fromname', $message['language'], '');
+      // Fix Recoverable fatal error: Object of class stdClass could not be converted to string
+      $langcode = isset($message['language']->language) ? $message['language']->language : language_default('language');
+      if (i18n_variable_get('smtp_fromname', $langcode, '') != '') {
+        $from_name = i18n_variable_get('smtp_fromname', $langcode, '');
       }
       else {
         // If value is not defined in settings, use site_name.
-        $from_name = i18n_variable_get('site_name', $message['language'], '');
+        $from_name = i18n_variable_get('site_name', $langcode, '');
       }
     }
-
+    
     if (variable_get('smtp_client_hostname', '') != '') {
       $mailer->Hostname = variable_get('smtp_client_hostname', '');
     }
CommentFileSizeAuthor
#3 smtp-and-i18n-node-2731417.patch1.26 KBmario.ugedo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mario.ugedo created an issue. See original summary.

mario.ugedo’s picture

Title: SmtpMailSystem::mailWithoutQueue » smtp and i18n
Issue summary: View changes
mario.ugedo’s picture

Hello!
the patch to fix Recoverable fatal error: Object of class stdClass could not be converted to string in _variable_store_load() (sites/all/modules/contrib/variable/variable_store/variable_store.module).

smtp-and-i18n-node-2731417.patch

wundo’s picture

Status: Active » Closed (duplicate)
apaderno’s picture

Issue tags: -SmtpMailSystem, -mailWithoutQueue, -i18n_variable_get, -$langcode