Skip to content

Commit 1dfe488

Browse files
committed
fix: use parse_url() only if scheme is not sqlite*
1 parent 78bc56f commit 1dfe488

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

DbalConnectionFactory.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,19 @@ private function establishConnection(): Connection
9191
return $this->connection;
9292
}
9393

94-
/**
95-
* @param string $dsn
96-
* @param array|null $config
97-
*
98-
* @return array
99-
*/
10094
private function parseDsn(string $dsn, array $config = null): array
10195
{
10296
if (false === strpos($dsn, ':')) {
10397
throw new \LogicException(sprintf('The DSN is invalid. It does not have scheme separator ":".'));
10498
}
10599

106-
if (false === parse_url($dsn)) {
100+
list($scheme) = explode(':', $dsn, 2);
101+
$scheme = strtolower($scheme);
102+
103+
if (false === strpos($scheme, 'sqlite') && false === parse_url($dsn)) {
107104
throw new \LogicException(sprintf('Failed to parse DSN "%s"', $dsn));
108105
}
109106

110-
list($scheme) = explode(':', $dsn, 2);
111-
112-
$scheme = strtolower($scheme);
113107
if (false == preg_match('/^[a-z\d+-.]*$/', $scheme)) {
114108
throw new \LogicException('The DSN is invalid. Scheme contains illegal symbols.');
115109
}
@@ -131,11 +125,7 @@ private function parseDsn(string $dsn, array $config = null): array
131125
];
132126

133127
if (false == isset($supported[$scheme])) {
134-
throw new \LogicException(sprintf(
135-
'The given DSN schema "%s" is not supported. There are supported schemes: "%s".',
136-
$scheme,
137-
implode('", "', array_keys($supported))
138-
));
128+
throw new \LogicException(sprintf('The given DSN schema "%s" is not supported. There are supported schemes: "%s".', $scheme, implode('", "', array_keys($supported))));
139129
}
140130

141131
$doctrineScheme = $supported[$scheme];

0 commit comments

Comments
 (0)