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

MasterSlaveConnection was BC Broken in 2.11.0 affecting doctrine/doctrine-bundle #4295

Closed
kralos opened this issue Sep 24, 2020 · 6 comments · Fixed by #4308
Closed

MasterSlaveConnection was BC Broken in 2.11.0 affecting doctrine/doctrine-bundle #4295

kralos opened this issue Sep 24, 2020 · 6 comments · Fixed by #4308

Comments

@kralos
Copy link

kralos commented Sep 24, 2020

Bug Report

Q A
BC Break yes
Version 2.11.0

Summary

Doctrine\DBAL\Connections\MasterSlaveConnection has changed how it handles $params (__construct arg 1). Specifically, it now unsets the legacy parameters master / slaves. This is a BC break because Doctrine\DBAL\Connection::getParams is public. Anything relying on these parameters will now break however the major version of doctrine/dbal was not bumped.

Current behaviour

For example doctrine/doctrine-bundle's Commands use the following code to extract connection params:

$params = $connection->getParams();
if (isset($params['master'])) {
    $params = $params['master'];
}

These commands now fail:

03:26:50 ERROR     [console] Error thrown while running command "{command}". Message: "{message}" ["exception" => InvalidArgumentException { …},"extra" => ["command" => "-v doctrine:database:create","message" => "Connection does not contain a 'path' or 'dbname' parameter and cannot be created."]]

In CreateDatabaseDoctrineCommand.php line 82:

  [InvalidArgumentException]                                                         
  Connection does not contain a 'path' or 'dbname' parameter and cannot be created.  

How to reproduce

$masterParam = [/***/];
$slavesParam = [/***/];
$conn = new \Doctrine\DBAL\Connections\MasterSlaveConnection([
    'master' => $masterParam,
    'slaves' => $slavesParam,
]);
\assert($conn->getParams()['master'] === $masterParam); // fails, used to pass in doctrine/dbal 2.10.4
\assert($conn->getParams()['slaves'] === $slavesParam); // fails, used to pass in doctrine/dbal 2.10.4

Expected behaviour

Doctrine\DBAL\Connections\MasterSlaveConnection should not unset($params['master']); / unset($params['slaves']);

@kralos kralos changed the title MasterSlaveConnection was BC Broken and now causes doctrine/doctrine-bundle to break MasterSlaveConnection was BC Broken in 2.11.0 affecting doctrine/doctrine-bundle Sep 24, 2020
@greg0ire
Copy link
Member

greg0ire commented Sep 25, 2020

On the one hand, this is indeed a BC-break, on the other hand, as pointed out by @stof, Connection::getParams() is marked as internal:

* @internal
*
* @return mixed[]
*/
public function getParams()
{
return $this->params;
}

It's like this since 2.11.0 though, maybe that should have been done in 3.0.0? Marking a method as internal sounds a bit like a BC-break. Anyway, we might revert this, but any piece of code relying on getParams() will have to be migrated in the future.

@kralos
Copy link
Author

kralos commented Sep 25, 2020

If it was marked @internal in 2.10.x I would have instead raised an issue in doctrine/doctrine-bundle. I don't think we need to revert, just bug fix the BC break by removing the unsets.

@greg0ire
Copy link
Member

I think it makes sense, can you send a PR?

kralos pushed a commit to kralos/dbal that referenced this issue Sep 27, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 27, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 27, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 27, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 28, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 28, 2020
kralos pushed a commit to kralos/dbal that referenced this issue Sep 28, 2020
ostrolucky added a commit that referenced this issue Oct 3, 2020
#4295 Keep master, slaves, keepReplica params in MasterSlaveConnection
@morozov
Copy link
Member

morozov commented Oct 16, 2020

Fixed by #4295.

@mvorisek
Copy link
Contributor

Fixed by #4295.

by #4308 :)

rgrellmann added a commit to Rossmann-IT/dbal that referenced this issue Mar 7, 2021
Release [2.11.2](https://github.com/doctrine/dbal/milestone/81)

2.11.2
======

- Total issues resolved: **5**
- Total pull requests resolved: **16**
- Total contributors: **10**

Static Analysis
---------------

 - [4353: Update Psalm to 3.17.2 and lock the version used with GitHub Actions](doctrine#4353) thanks to @morozov
 - [4348: Bump Psalm level to 3](doctrine#4348) thanks to @morozov
 - [4332: Static analysis improvements](doctrine#4332) thanks to @morozov
 - [4319: Bump Psalm level to 4](doctrine#4319) thanks to @morozov

Code Style
----------

 - [4346: Minor CS improvement - use ::class for TestCase::expectException input](doctrine#4346) thanks to @mvorisek

 - [4344: Static analysis workflow](doctrine#4344) thanks to @greg0ire
 - [4340: Modernize existing ga](doctrine#4340) thanks to @greg0ire
 - [4309: Use cache action v2](doctrine#4309) thanks to @greg0ire
 - [4305: Move website config to default branch](doctrine#4305) thanks to @SenseException

Improvement,Prepared Statements
-------------------------------

 - [4341: Add Statement::fetchAllIndexedAssociative() and ::iterateIndexedAssociative()](doctrine#4341) thanks to @morozov and @ZaneCEO
 - [4338: Add Statement::fetchAllKeyValue() and ::iterateKeyValue()](doctrine#4338) thanks to @morozov

BC Fix,Query
------------

 - [4330: Fix regression in QueryBuilder::and|orWhere()](doctrine#4330) thanks to @BenMorel

Test Suite
----------

 - [4321: Update PHPUnit to 9.4](doctrine#4321) thanks to @morozov

Columns,SQL Server,Schema Managers
----------------------------------

 - [4315: Fix handling existing SQL Server column comment when other properties change](doctrine#4315) thanks to @trusek

CI
--

 - [4310: Migrate jobs away from Travis to Github Actions ](doctrine#4310) thanks to @greg0ire

BC Fix,Connections
------------------

 - [4308: doctrine#4295 Keep master, slaves, keepReplica params in MasterSlaveConnection](doctrine#4308) thanks to @kralos

New Feature,Prepared Statements
-------------------------------

 - [4289: Add a fetch mode methods for "PDO::FETCH&doctrine#95;KEY&doctrine#95;PAIR"](doctrine#4289) thanks to @tswcode

Bug,SQL Server,Schema
---------------------

 - [3400: Wrong column comment setting command in migrations of SQL Server](doctrine#3400) thanks to @msyfurukawa

# gpg: Signature made Mon Oct 19 04:18:17 2020
# gpg:                using DSA key 1BEDEE0A820BC30D858F9F0C2C3A645671828132
# gpg: Can't check signature: No public key
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants