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

Configuring Connection with Driver instance legacy but not deprecated #17641

Open
othercorey opened this issue Mar 20, 2024 · 3 comments
Open

Comments

@othercorey
Copy link
Member

Description

https://github.com/cakephp/cakephp/blob/5.x/src/Database/Connection.php#L139-L147

In Connection::createDrivers(), passing in a Driver instance is marked legacy, but this config path was not marked deprecated in 5.0.

Is this still considered legacy and should it be deprecated?

if (!is_string($driver)) {
    assert($driver instanceof Driver);
    if (!$driver->enabled()) {
        throw new MissingExtensionException(['driver' => get_class($driver), 'name' => $this->configName()]);
    }

    // Legacy support for setting instance instead of driver class
    return [self::ROLE_READ => $driver, self::ROLE_WRITE => $driver];
}

CakePHP Version

5.0

PHP Version

No response

@othercorey othercorey added this to the 5.1.0 milestone Mar 20, 2024
@othercorey
Copy link
Member Author

CakePHP 4 had Connection::setDriver() which might be a part of this support.

https://github.com/cakephp/cakephp/blob/4.x/src/Database/Connection.php#L251

We dropped setDriver() in 5.0.

@ADmad
Copy link
Member

ADmad commented Mar 21, 2024

I am pretty sure the setDriver() was primarily for testing and doesn't have an actual use case.

@markstory
Copy link
Member

Is this still considered legacy and should it be deprecated?

I would say yes. I can't think of any scenarios in the framework where we need to pass driver instances in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants