Skip to content

Commit 11a2199

Browse files
authored
Merge pull request #453 from coudenysj/parse_url_underscore_scheme
PHP_URL_SCHEME doesn't support underscores
2 parents e173991 + 97de12b commit 11a2199

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎pkg/dbal/DbalConnectionFactory.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ private function parseDsn($dsn)
9898
throw new \LogicException(sprintf('Failed to parse DSN "%s"', $dsn));
9999
}
100100

101-
$schema = parse_url($dsn, PHP_URL_SCHEME);
102-
if (empty($schema)) {
101+
if (!preg_match('/^([0-9a-z_]+):(.+)?$/', $dsn, $matches)) {
103102
throw new \LogicException('Schema is empty');
104103
}
104+
$schema = $matches[1];
105105

106106
$supported = [
107107
'db2' => true,

‎pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ public static function provideConfigs()
7272
],
7373
];
7474

75+
yield [
76+
'pdo_mysql:',
77+
[
78+
'lazy' => true,
79+
'connection' => [
80+
'url' => 'pdo_mysql://root@localhost',
81+
],
82+
],
83+
];
84+
7585
yield [
7686
'pgsql:',
7787
[
@@ -92,6 +102,16 @@ public static function provideConfigs()
92102
],
93103
];
94104

105+
yield [
106+
'pdo_mysql://user:pass@host:10001/db',
107+
[
108+
'lazy' => true,
109+
'connection' => [
110+
'url' => 'pdo_mysql://user:pass@host:10001/db',
111+
],
112+
],
113+
];
114+
95115
yield [
96116
[],
97117
[

0 commit comments

Comments
 (0)