Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9716a89

Browse filesBrowse files
committed
Simplify code
1 parent c5703ae commit 9716a89
Copy full SHA for 9716a89

File tree

1 file changed

+7
-7
lines changed
Filter options

1 file changed

+7
-7
lines changed

‎src/Symfony/Component/Mailer/Transport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Transport.php
+7-7
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public function fromStrings(#[\SensitiveParameter] array $dsns): Transports
107107
public function fromString(#[\SensitiveParameter] string $dsn): TransportInterface
108108
{
109109
[$transport, $offset] = $this->parseDsn($dsn);
110-
$dnsWithoutMainOptions = preg_replace('/[?&]retry_period=\d+/', '', $dsn);
111-
if ($offset !== \strlen($dnsWithoutMainOptions)) {
110+
if ($offset !== \strlen($dsn)) {
112111
throw new InvalidArgumentException('The mailer DSN has some garbage at the end.');
113112
}
114113

@@ -122,10 +121,6 @@ private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0):
122121
'roundrobin' => RoundRobinTransport::class,
123122
];
124123

125-
$parsedUrl = parse_url($dsn);
126-
parse_str($parsedUrl['query'] ?? '', $query);
127-
$retryPeriod = min((int) ($query['retry_period'] ?? 60), 60);
128-
129124
while (true) {
130125
foreach ($keywords as $name => $class) {
131126
$name .= '(';
@@ -150,7 +145,12 @@ private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0):
150145
}
151146
}
152147

153-
return [new $class($args, $retryPeriod), $offset];
148+
parse_str(substr($dsn, $offset + 1), $query);
149+
if ($period = $query['retry_period'] ?? 0) {
150+
return [new $class($args, (int) $period), $offset + \strlen('retry_period='.$period) + 1];
151+
}
152+
153+
return [new $class($args), $offset];
154154
}
155155
}
156156

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.