Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection DSN can omit password #971

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function connect($dsn, string $user = null, string $password = nul
case 'pdo_sqlsrv':
case 'pdo_oci':
case 'oci8':
$persistence = new Persistence\Sql($dsn, $dsn['user'], $dsn['password'], $args);
$persistence = new Persistence\Sql($dsn, $dsn['user'] ?? null, $dsn['password'] ?? null, $args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connection string with empty password and in such case password is not set in dsn array

why $dsn['user'] ?? null then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, why not to use http://username:@example.com as DSN for empty password?

Copy link
Member Author

@DarkSide666 DarkSide666 Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://username:@ also don't set password key in dsn array and using ?? null to avoid exception in case password (or user) keys are not set in dsn array.
Maybe we need to do this validation in Connection class instead and always pass user and password keys even if they are null (not set).


return $persistence;
default:
Expand Down