-
-
Notifications
You must be signed in to change notification settings - Fork 154
fix OutOfBoundsException when using mail or sendmail transport #42
Conversation
Can you add a test covering this issue to avoid regressions ? |
I don't know how to test this, the exception occured when we call the replaceArgument on the DefinitionDecorator class but it is the Definition::replaceArgument method which is really called |
does your test fail if you undo your patch ? This is the good way to see if the test is accurate: failing without the patch and passing with it |
I can't reproduce the bug inside the bundle with phpunit and the bundles vendors, but without this patch it failed every time on my symfony 2.3 project |
I think in a real symfony project the definition decorator doesn't respect fully the service configuration set in swiftmailer.xml : <service id="swiftmailer.transport.sendmail.abstract" class="%swiftmailer.transport.sendmail.class%" abstract="true" public="false">
<argument type="service" id="swiftmailer.transport.buffer" />
</service>
<service id="swiftmailer.transport.mail.abstract" class="%swiftmailer.transport.mail.class%" abstract="true" public="false">
<argument type="service" id="swiftmailer.transport.mailinvoker" />
</service> compared to : } elseif (in_array($transport, array('mail', 'sendmail'))) {
$definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.transport.%s.abstract', $transport));
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)
->addArgument(new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)))
;
$container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));
} |
Maybe an explicit definition arguments settings will be clearer : } elseif ('sendmail' === $transport) {
$definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.transport.%s.abstract', $transport));
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)
->setArguments(array(
new Reference('swiftmailer.transport.buffer'),
new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),
))
;
$container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));
} elseif ('mail' === $transport) {
$definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.transport.%s.abstract', $transport));
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)
->setArguments(array(
new Reference('swiftmailer.transport.mailinvoker'),
new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),
))
;
$container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));
} |
👍 I'm facing the same bug (since #34 has been merged) and I can confirm this patch fixes it. |
Hi,
Since the #34 had been merged, an exception occured when using mail or sendmail transport :
This patch fix it.