From: x2003bruneau Date: Thu, 1 Feb 2007 10:28:45 +0000 (+0000) Subject: Fix massmailer memory usage X-Git-Tag: xorg/0.9.13~25 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=c87621cccffec16852114cb6c611bb782c1bbffa;p=platal.git Fix massmailer memory usage git-svn-id: svn+ssh://murphy/home/svn/platal/branches/platal-0.9.13@1455 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/plmailer.php b/classes/plmailer.php index 9468fa3..5d38bb2 100644 --- a/classes/plmailer.php +++ b/classes/plmailer.php @@ -28,11 +28,10 @@ class PlMail extends Smarty private $tpl; private $mailer = null; - function __construct(&$mailer, $tpl) + function __construct($tpl) { global $globals; $this->tpl = $tpl; - $this->mailer =& $mailer; $this->caching = false; $this->compile_check = true; @@ -50,6 +49,16 @@ class PlMail extends Smarty $this->register_function('add_header', Array($this, 'addHeader')); } + public static function &get(&$mailer, $tpl) + { + static $plmail; + if (!isset($plmail) || $plmail->tpl != $tpl) { + $plmail = new PlMail($tpl); + } + $plmail->mailer =& $mailer; + return $plmail; + } + public function run($html) { $this->assign('html_version', $html); @@ -146,7 +155,7 @@ class PlMailer extends Mail_Mime { $this->Mail_Mime("\n"); $this->mail = @Mail::factory('sendmail', Array('sendmail_args' => '-oi')); if (!is_null($tpl)) { - $this->page = new PlMail($this, $tpl); + $this->page =& PlMail::get($this, $tpl); } } diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index 79b0fa0..77a38b2 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -121,7 +121,8 @@ abstract class MassMailer protected function getAllRecipients() { - return "SELECT u.user_id, a.alias, + global $globals; + return "SELECT u.user_id, CONCAT(a.alias, '@{$globals->mail->domain}'), u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage), FIND_IN_SET('femme', u.flags), q.core_mail_fmt AS pref, 0 AS hash @@ -151,6 +152,7 @@ abstract class MassMailer XDB::execute("UPDATE {$this->subscriptionTable()} SET last = {?} WHERE " . implode(' OR ', $sent), $this->_id); + sleep(60); } }