Skip to content

Connection DSN can omit password#971

Merged
mvorisek merged 1 commit intodevelopfrom
feature/fix_empty_password
Mar 2, 2022
Merged

Connection DSN can omit password#971
mvorisek merged 1 commit intodevelopfrom
feature/fix_empty_password

Conversation

@DarkSide666
Copy link
Copy Markdown
Member

We can have connection string with empty password and in such case password is not set in dsn array.
This should fix that.

For example

'dsn' => "mysql://root@localhost:3307/my_dbase;charset=utf8mb4",

@DarkSide666 DarkSide666 requested a review from mvorisek March 2, 2022 17:24
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

@mvorisek
Copy link
Copy Markdown
Member

mvorisek commented Mar 2, 2022

PR LGTM, especially for sqlite DSN

@mvorisek mvorisek changed the title connection strings can omit password Connection DSC can omit password Mar 2, 2022
@mvorisek mvorisek changed the title Connection DSC can omit password Connection DSN can omit password Mar 2, 2022
@mvorisek mvorisek merged commit fd25cb8 into develop Mar 2, 2022
@mvorisek mvorisek deleted the feature/fix_empty_password branch March 2, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants