Skip to content

Commit

Permalink
Fixed issue #18559: Potential 500 error with LimeMailer and PHP8 (#2799)
Browse files Browse the repository at this point in the history
Dev: Use PHPMailer default for all if empty by plugin (or before)
Dev: really needed currently by to only
Dev: $event->get('send', true) need loose compare
Dev: more comment about don't break API
  • Loading branch information
Shnoulle committed Feb 15, 2023
1 parent be70f93 commit c5d6d55
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions application/core/LimeMailer.php
Expand Up @@ -515,25 +515,29 @@ private function manageEvent($eventParams = array())
$event->set('updateDisable', array());
App()->getPluginManager()->dispatchEvent($event);
/* Manage what can be updated */
/* For default (if is empty) use default from PHPMailer (avoiding set to null) */
$updateDisable = $event->get('updateDisable');
if (empty($updateDisable['subject'])) {
$this->Subject = $event->get('subject');
$this->Subject = $event->get('subject', '');
}
if (empty($updateDisable['body'])) {
$this->Body = $event->get('body');
$this->Body = $event->get('body', '');
}
if (empty($updateDisable['from'])) {
$this->setFrom($event->get('from'));
$this->setFrom($event->get('from', ''));
}
if (empty($updateDisable['to'])) {
/* Warning : pre 4 version send array of string, here we send array of array (email+name) */
$this->to = $event->get('to');
/* Set default as array to avoid the to to null and broke on PHP8 */
$this->to = $event->get('to', array());
}
if (empty($updateDisable['bounce'])) {
$this->Sender = $event->get('bounce');
$this->Sender = $event->get('bounce', '');
}
$this->eventMessage = $event->get('message');
if ($event->get('send', true) == false) {
/* Need loose compare : if null, return true (default) */
/* Plugin can send anything for false : don't break API by move to strict compare */
if (!$event->get('send', true)) {
$this->ErrorInfo = $event->get('error');
return $event->get('error') == null;
}
Expand Down Expand Up @@ -882,7 +886,7 @@ public function addAttachementsByType()
if (!array_key_exists($this->emailType, $this->_aAttachementByType)) {
return;
}

$attachementType = $this->_aAttachementByType[$this->emailType];
$oSurveyLanguageSetting = SurveyLanguageSetting::model()->findByPk(array('surveyls_survey_id' => $this->surveyId, 'surveyls_language' => $this->mailLanguage));
if (!empty($oSurveyLanguageSetting->attachments)) {
Expand Down

0 comments on commit c5d6d55

Please sign in to comment.