]> git.agnieray.net Git - galette.git/blobdiff - galette/lib/Galette/Core/Mailing.php
Fix mailing preview; fixes #1800
[galette.git] / galette / lib / Galette / Core / Mailing.php
index 5a93f5464c113cd4a2dffd9fcf15fad4f049e0f1..e2344014d58341e623a48eff892a3558d1337966 100644 (file)
@@ -192,7 +192,15 @@ class Mailing extends GaletteMail
     {
         global $zdb;
 
-        $orig_recipients = unserialize($rs->mailing_recipients);
+        try {
+            $orig_recipients = unserialize($rs->mailing_recipients);
+        } catch (\Throwable $e) {
+            Analog::log(
+                'Unable to unserialize recipients for mailing ' . $rs->mailing_id,
+                Analog::ERROR
+            );
+            $orig_recipients = [];
+        }
 
         $_recipients = array();
         $mdeps = ['parent' => true];
@@ -203,6 +211,7 @@ class Mailing extends GaletteMail
         $this->setRecipients($_recipients);
         $this->subject = $rs->mailing_subject;
         $this->message = $rs->mailing_body;
+        $this->html = $this->message != strip_tags($this->message) ? true : false;
         if ($rs->mailing_sender_name !== null || $rs->mailing_sender_address !== null) {
             $this->setSender(
                 $rs->mailing_sender_name,
@@ -503,7 +512,7 @@ class Mailing extends GaletteMail
     /**
      * Global getter method
      *
-     * @param string $name name of the property we want to retrive
+     * @param string $name name of the property we want to retrieve
      *
      * @return mixed the called property
      */
@@ -566,7 +575,7 @@ class Mailing extends GaletteMail
      * Global isset method
      * Required for twig to access properties via __get
      *
-     * @param string $name name of the property we want to retrive
+     * @param string $name name of the property we want to retrieve
      *
      * @return bool
      */
@@ -601,9 +610,9 @@ class Mailing extends GaletteMail
      * Global setter method
      *
      * @param string $name  name of the property we want to assign a value to
-     * @param object $value a relevant value for the property
+     * @param mixed  $value a relevant value for the property
      *
-     * @return void|false
+     * @return void
      */
     public function __set($name, $value)
     {
@@ -649,10 +658,9 @@ class Mailing extends GaletteMail
                 break;
             default:
                 Analog::log(
-                    '[' . get_class($this) . '] Unable to set proprety `' . $name . '`',
+                    '[' . get_class($this) . '] Unable to set property `' . $name . '`',
                     Analog::WARNING
                 );
-                return false;
         }
     }
 }