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 with driverOptions now broken outside of create/drop commands #1252

Closed
petewalker opened this issue Nov 10, 2020 · 0 comments · Fixed by #1253
Closed

Comments

@petewalker
Copy link
Contributor

Follow-up from #1230

The fix in #1240 has allowed doctrine:database:create and doctrine:database:drop to work, but it's broken pretty much everything else in v1.12.11

The change in the above PR moves the driverOptions from the root of the connection params array into master (if you're using MasterSlaveConnection.

This is fine in the create/drop commands, because they manipulate the params array before the connection is made, and build a new one.

However, the base MasterSlaveConnection expects the driverOptions to be in the root of the params array:

    /**
     * Connects to a specific connection.
     *
     * @param string $connectionName
     *
     * @return DriverConnection
     */
    protected function connectTo($connectionName)
    {
        $params = $this->getParams();

        $driverOptions = $params['driverOptions'] ?? [];

        $connectionParams = $this->chooseConnectionConfiguration($connectionName, $params);

        $user     = $connectionParams['user'] ?? null;
        $password = $connectionParams['password'] ?? null;

        return $this->_driver->connect($connectionParams, $user, $password, $driverOptions);
    }

So, if you try to run doctrine:migrations:migrate with driverOptions (in my case TLS configuration), you get this:

In AbstractMySQLDriver.php line 110:
                                                                                                                       
  An exception occurred in driver: SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while -  
  -require_secure_transport=ON.                                                                                        
                                                                                                                       

In PDOConnection.php line 31:
                                                                                                                   
  SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while --require_secure_transport=ON.  
                                                                                                                   

In PDOConnection.php line 27:
                                                                                                                   
  SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while --require_secure_transport=ON. 

I think a better fix for now would be to revert this change, and add some special behaviour to the create/drop commands?

petewalker added a commit to petewalker/DoctrineBundle that referenced this issue Nov 10, 2020
…verOptions

Reverts the changes made in doctrine#1240, and applies the passing down of `driverOptions` manually in `CreateDatabaseDoctrineCommand` and `DropDatabaseDoctrineCommand`

Resolves doctrine#1252
@ostrolucky ostrolucky added this to the 2.2.1 milestone Nov 10, 2020
@ostrolucky ostrolucky modified the milestones: 2.2.1, 1.12.13 Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants