From 15c666bf436748e005127207f46a9a2289a5b234 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 19 Jan 2012 12:11:55 -0800 Subject: [PATCH 1/3] Add a "recover-timeout" option to allow recovering messages that have taken too long to send --- .../Bundle/SwiftmailerBundle/Command/SendEmailCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php index 5992b2faad..657a5d35a9 100644 --- a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php +++ b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php @@ -34,10 +34,11 @@ class SendEmailCommand extends ContainerAwareCommand ->setDescription('Sends emails from the spool') ->addOption('message-limit', 0, InputOption::VALUE_OPTIONAL, 'The maximum number of messages to send.') ->addOption('time-limit', 0, InputOption::VALUE_OPTIONAL, 'The time limit for sending messages (in seconds).') + ->addOption('recover-timeout', 0, InputOption::VALUE_OPTIONAL, 'The timeout for recovering messages that have taken too long to send (in seconds).') ->setHelp(<<swiftmailer:spool:send command sends all emails from the spool. -php app/console swiftmailer:spool:send --message-limit=10 --time-limit=10 +php app/console swiftmailer:spool:send --message-limit=10 --time-limit=10 --recover-timeout=900 EOF ) @@ -57,6 +58,7 @@ EOF if ($spool instanceof \Swift_ConfigurableSpool) { $spool->setMessageLimit($input->getOption('message-limit')); $spool->setTimeLimit($input->getOption('time-limit')); + NULL !== $input->getOption('recover-timeout') ? $spool->recover($input->getOption('recover-timeout')) : $spool->recover(); } $sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real')); From d2a0c74e22a20f1860d80d907670b72475363714 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 19 Jan 2012 13:01:29 -0800 Subject: [PATCH 2/3] Use if/else instead of ternary operator --- .../Bundle/SwiftmailerBundle/Command/SendEmailCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php index 657a5d35a9..47b1d08714 100644 --- a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php +++ b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php @@ -58,7 +58,11 @@ EOF if ($spool instanceof \Swift_ConfigurableSpool) { $spool->setMessageLimit($input->getOption('message-limit')); $spool->setTimeLimit($input->getOption('time-limit')); - NULL !== $input->getOption('recover-timeout') ? $spool->recover($input->getOption('recover-timeout')) : $spool->recover(); + if (null !== $input->getOption('recover-timeout')) { + $spool->recover($input->getOption('recover-timeout')); + } else { + $spool->recover(); + } } $sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real')); From 9e55cdaeecac8870fc4decebd3abb39160effe7c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 21 Jan 2012 00:49:31 -0800 Subject: [PATCH 3/3] Only call recover() when spool is a Swift_FileSpool --- .../Bundle/SwiftmailerBundle/Command/SendEmailCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php index 47b1d08714..f6804143a7 100644 --- a/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php +++ b/src/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php @@ -58,6 +58,8 @@ EOF if ($spool instanceof \Swift_ConfigurableSpool) { $spool->setMessageLimit($input->getOption('message-limit')); $spool->setTimeLimit($input->getOption('time-limit')); + } + if ($spool instanceof \Swift_FileSpool) { if (null !== $input->getOption('recover-timeout')) { $spool->recover($input->getOption('recover-timeout')); } else {