Download tasks/2257a3ebd6ffa8cc/source/patch.diff from FuCY/php: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/2257a3ebd6ffa8cc/source/patch.diff
- Command line
-
hf download hf://datasets/FuCY/php/tasks/2257a3ebd6ffa8cc/source/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/2257a3ebd6ffa8cc/source/patch.diff
2.81 kB
| diff --git a/src/Core/Content/Mail/Service/MailerTransportFactory.php b/src/Core/Content/Mail/Service/MailerTransportFactory.php | |
| index 6b4ccac68d9..72400df9e78 100644 | |
| --- a/src/Core/Content/Mail/Service/MailerTransportFactory.php | |
| +++ b/src/Core/Content/Mail/Service/MailerTransportFactory.php | |
| public function create(?SystemConfigService $configService = null): TransportInt | |
| case 'smtp': | |
| return $this->createSmtpTransport($configService); | |
| case 'local': | |
| - return new SendmailTransport('/usr/sbin/sendmail ' . ($configService->getString('core.mailerSettings.sendMailOptions') ?: '-bs')); | |
| + return new SendmailTransport($this->getSendMailCommandLineArgument($configService)); | |
| default: | |
| throw new \RuntimeException(sprintf('Invalid mail agent given "%s"', $emailAgent)); | |
| } | |
| private function getEncryption(SystemConfigService $configService): ?string | |
| return null; | |
| } | |
| } | |
| + | |
| + private function getSendMailCommandLineArgument(SystemConfigService $configService): string | |
| + { | |
| + $command = '/usr/sbin/sendmail '; | |
| + | |
| + $option = $configService->getString('core.mailerSettings.sendMailOptions'); | |
| + | |
| + if ($option === '') { | |
| + $option = '-t'; | |
| + } | |
| + | |
| + if ($option !== '-bs' && $option !== '-t') { | |
| + throw new \RuntimeException(sprintf('Given sendmail option "%s" is invalid', $option)); | |
| + } | |
| + | |
| + return $command . $option; | |
| + } | |
| } | |
| diff --git a/src/Core/Content/Test/MailTemplate/Service/MailerTransportFactoryTest.php b/src/Core/Content/Test/MailTemplate/Service/MailerTransportFactoryTest.php | |
| index 013cb15ff64..8fbb9a20995 100644 | |
| --- a/src/Core/Content/Test/MailTemplate/Service/MailerTransportFactoryTest.php | |
| +++ b/src/Core/Content/Test/MailTemplate/Service/MailerTransportFactoryTest.php | |
| public function testFactoryWithConfig(): void | |
| static::assertEquals(\get_class($original), \get_class($mailer)); | |
| } | |
| + | |
| + public function testFactoryWithLocalAndInvalidConfig(): void | |
| + { | |
| + $original = new SendmailTransport(); | |
| + | |
| + $factory = $this->getContainer()->get('mailer.transport_factory'); | |
| + | |
| + static::expectException(\RuntimeException::class); | |
| + static::expectExceptionMessage('Given sendmail option "-t && echo bla" is invalid'); | |
| + | |
| + $mailer = $factory->create( | |
| + new ConfigService([ | |
| + 'core.mailerSettings.emailAgent' => 'local', | |
| + 'core.mailerSettings.sendMailOptions' => '-t && echo bla', | |
| + ]) | |
| + ); | |
| + | |
| + static::assertEquals(\get_class($original), \get_class($mailer)); | |
| + } | |
| } | |
| class ConfigService extends SystemConfigService | |