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

Fix #1230 - Console commands do not respect driverOptions when master/slave configuration is used #1240

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ protected function getConnectionOptions($connection)
if (! empty($options['slaves'])) {
$nonRewrittenKeys = [
'driver' => true,
'driverOptions' => true,
'driverClass' => true,
'wrapperClass' => true,
'keepSlave' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function testDbalLoadSingleMasterSlaveConnection()
'dbname' => 'mysql_db',
'host' => 'localhost',
'unix_socket' => '/path/to/mysqld.sock',
'driverOptions' => [],
Copy link
Member

Choose a reason for hiding this comment

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

Should the file on line 114 be modified to add options in both the master and the slave, to make things more interesting? Without your change, what happens? Are the master's options copied to the slave?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is actually no such option as "master" configuration key/option. What's defined one level above slaves is what's master. And yes that's how this patch works. It copies everything from master to slaves except the things in the list.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, I read the issue backwards. What if there is already an option at the slave level? Will it be overwritten? Should the configuration at

dbal:
dbname: mysql_db
user: mysql_user
password: mysql_s3cr3t
unix_socket: /path/to/mysqld.sock
keep_slave: true
default_table_options:
engine: InnoDB
slaves:
slave1:
user: slave_user
dbname: slave_db
password: slave_s3cr3t
unix_socket: /path/to/mysqld_slave.sock
be modified to test what happens when there are options in both levels? I'd expect some kind of merge to happen, but I'm not sure which level should get the priority. Maybe the slave one, because otherwise, there would be a BC-break?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's necessary. I didn't change merging logic. Whatever slave specifies is kept for that slave.

],
$param['master']
);
Expand Down