diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php index 16612e2640..bf17683ab5 100644 --- a/lib/Models/Newsletter.php +++ b/lib/Models/Newsletter.php @@ -119,9 +119,9 @@ class Newsletter extends Model { $this->set_expr('deleted_at', 'NULL'); } - if (isset($this->body)) { + if (isset($this->body) && ($this->body !== false)) { if (is_array($this->body)) { - $this->body = json_encode($this->body); + $this->body = (string)json_encode($this->body); } $this->set( 'body', diff --git a/lib/Models/ScheduledTask.php b/lib/Models/ScheduledTask.php index 86355f564d..9a1eebe7e1 100644 --- a/lib/Models/ScheduledTask.php +++ b/lib/Models/ScheduledTask.php @@ -98,7 +98,7 @@ class ScheduledTask extends Model { if (!is_null($this->meta) && !Helpers::isJson($this->meta)) { $this->set( 'meta', - json_encode($this->meta) + (string)json_encode($this->meta) ); } parent::save(); diff --git a/lib/Models/Segment.php b/lib/Models/Segment.php index 143289669a..1eebbae1b3 100644 --- a/lib/Models/Segment.php +++ b/lib/Models/Segment.php @@ -84,7 +84,7 @@ class Segment extends Model { } public function withSubscribersCount() { - $this->subscribersCount = SubscriberSegment::tableAlias('relation') + $query = SubscriberSegment::tableAlias('relation') ->where('relation.segment_id', $this->id) ->join( MP_SUBSCRIBERS_TABLE, @@ -117,8 +117,11 @@ class Segment extends Model { Subscriber::STATUS_BOUNCED ) ->whereNull('subscribers.deleted_at') - ->findOne() - ->asArray(); + ->findOne(); + + if ($query instanceof SubscriberSegment) { + $this->subscribersCount = $query->asArray(); + } return $this; }