Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2022-08-14 17:02:56 +0300
committerAleksander Machniak <alec@alec.pl>2022-08-14 17:02:56 +0300
commit0a3a332866644ecf9aea34f4da480de73850bda5 (patch)
tree9152bed12fe80346ab870c666a4f5e5379e95f73
parent825bcf5af70f072d5238f4eed95999b6016aa945 (diff)
Fix PHP Deprecated: Creation of dynamic property Mail_mime::$mailbody_file is deprecated
-rw-r--r--plugins/markasjunk/drivers/email_learn.php1
-rw-r--r--program/include/rcmail_sendmail.php45
2 files changed, 26 insertions, 20 deletions
diff --git a/plugins/markasjunk/drivers/email_learn.php b/plugins/markasjunk/drivers/email_learn.php
index 7d639ff06..6d41d0406 100644
--- a/plugins/markasjunk/drivers/email_learn.php
+++ b/plugins/markasjunk/drivers/email_learn.php
@@ -145,7 +145,6 @@ class markasjunk_email_learn
}
$SENDMAIL->deliver_message($MAIL_MIME, $i == count($uids) - 1);
- $message_file = $message_file ?: $MAIL_MIME->mailbody_file;
// clean up
if ($message_file) {
diff --git a/program/include/rcmail_sendmail.php b/program/include/rcmail_sendmail.php
index a8a9a34b8..ed67f52bb 100644
--- a/program/include/rcmail_sendmail.php
+++ b/program/include/rcmail_sendmail.php
@@ -33,6 +33,7 @@ class rcmail_sendmail
protected $parse_data = [];
protected $message_form;
protected $rcmail;
+ protected $temp_files = [];
// define constants for message compose mode
const MODE_NONE = 'none';
@@ -76,6 +77,16 @@ class rcmail_sendmail
}
/**
+ * Object destructor to cleanup temporary files
+ */
+ public function __destruct()
+ {
+ foreach ($this->temp_files as $file) {
+ @unlink($file);
+ }
+ }
+
+ /**
* Collect input data for message headers
*
* @return array Message headers
@@ -448,7 +459,9 @@ class rcmail_sendmail
return false;
}
- $message->mailbody_file = $mailbody_file;
+ if ($mailbody_file) {
+ $this->temp_files[$message->headers()['Message-ID']] = $mailbody_file;
+ }
// save message sent time
if ($this->options['sendmail_delay']) {
@@ -524,22 +537,21 @@ class rcmail_sendmail
// append message to sent box
if ($store_folder) {
// message body in file
- if (!empty($message->mailbody_file) || $message->getParam('delay_file_io')) {
- $headers = $message->txtHeaders();
+ $msg_id = $message->headers()['Message-ID'];
- // file already created
- if (!empty($message->mailbody_file)) {
- $msg = $message->mailbody_file;
- }
- else {
- $message->mailbody_file = rcube_utils::temp_filename('msg');
- $msg = $message->saveMessageBody($message->mailbody_file);
+ if ($message->getParam('delay_file_io') && empty($this->temp_files[$msg_id])) {
+ $msg_file = rcube_utils::temp_filename('msg');
+ $msg = $message->saveMessageBody($msg_file);
- if (!is_a($msg, 'PEAR_Error')) {
- $msg = $message->mailbody_file;
- }
+ if (!is_a($msg, 'PEAR_Error')) {
+ $this->temp_files[$msg_id] = $msg_file;
}
}
+
+ if (!empty($this->temp_files[$msg_id])) {
+ $msg = $this->temp_files[$msg_id];
+ $headers = $message->txtHeaders();
+ }
else {
$msg = $message->getMessage();
$headers = '';
@@ -552,7 +564,7 @@ class rcmail_sendmail
true, false);
}
else {
- $is_file = !empty($message->mailbody_file);
+ $is_file = !empty($this->temp_files[$msg_id]);
$saved = $storage->save_message($store_target, $msg, $headers, $is_file, ['SEEN']);
}
}
@@ -565,11 +577,6 @@ class rcmail_sendmail
}
}
- if (!empty($message->mailbody_file)) {
- unlink($message->mailbody_file);
- unset($message->mailbody_file);
- }
-
$this->options['store_target'] = $store_target;
$this->options['store_folder'] = $store_folder;