You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for URL-like DSNs for the PdoSessionHandler
This allows migrating away from the deprecated DbalSessionHandler when
DBAL was used for its ability to be configured through a URL (which is
what is provided on Heroku and some other PaaS).
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
if (isset($params['host']) && '' !== $params['host']) {
492
+
$dsn .= 'host='.$params['host'].';';
493
+
}
494
+
495
+
if (isset($params['port']) && '' !== $params['port']) {
496
+
$dsn .= 'port='.$params['port'].';';
497
+
}
498
+
499
+
if (isset($params['path'])) {
500
+
$dbName = substr($params['path'], 1); // Remove the leading slash
501
+
$dsn .= 'dbname='.$dbName.';';
502
+
}
503
+
504
+
return$dsn;
505
+
506
+
case'sqlite':
507
+
return'sqlite:'.substr($params['path'], 1);
508
+
509
+
case'sqlsrv':
510
+
$dsn = 'sqlsrv:server=';
511
+
512
+
if (isset($params['host'])) {
513
+
$dsn .= $params['host'];
514
+
}
515
+
516
+
if (isset($params['port']) && '' !== $params['port']) {
517
+
$dsn .= ','.$params['port'];
518
+
}
519
+
520
+
if (isset($params['path'])) {
521
+
$dbName = substr($params['path'], 1); // Remove the leading slash
522
+
$dsn .= ';Database='.$dbName;
523
+
}
524
+
525
+
return$dsn;
526
+
527
+
default:
528
+
thrownew \InvalidArgumentException(sprintf('The scheme "%s" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.', $params['scheme']));
0 commit comments