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 implements MasterSlaveConnectionInterface in or… #2890

Closed
wants to merge 1 commit into from
Closed

Conversation

ionuttocila
Copy link

…der to remove dependency of concrete class implementation

…der to remove dependency of concrete class implementation
@lcobucci
Copy link
Member

@alteringres why are you depending on that implementation and not on the Connection interface? Does your application behaves differently because of that?

That implementation is not an extension point of DBAL so IMO it shouldn't have an interface, maybe @Ocramius and @deeky666 can have a different opinion but I'd say this should be a won't fix.

@lcobucci
Copy link
Member

This class should be final too 😜

@ionuttocila
Copy link
Author

ionuttocila commented Oct 21, 2017

Because MasterSlaveConnection does not implement an interface which represents the public API of master/slave logic, other packages like doctrine/migrations will do fixes like:
doctrine/migrations#479
so, when this combines with Symfony Doctrine Configuration which allows the usage of custom master/slave wrappers (others then the MasterSlaveConnection provided by DBAL), some functions will not work any more (in this example, migrations will not work any more if wrapper is changed into another class)

In my opinion, other packages should not check a concrete class implementation, but an interface which can be implemented by anyone in other ways, keeping the same public API.

I've got this problem, so I created this PR to create the interface, then I'll create another PR to fix doctrine/migrations

@lcobucci
Copy link
Member

Because MasterSlaveConnection does not implement an interface which represents the public API of master/slave logic, other packages like doctrine/migrations will do fixes like:
doctrine/migrations#479

@alteringres IMO doctrine/migrations should never force the connection to master, that reveals an encapsulation issue on the MasterSlaveConnection (we should rather hear from @Ocramius and @mikeSimonson to have some context on this).

In my opinion, other packages should not check a concrete class implementation, but an interface which can be implemented by anyone in other ways, keeping the same public API.

You're correct, however that's only applicable when it was designed in that way (as an extension point). In this case I still think that the MasterSlaveConnection should be 100% transparent for every single piece of code that relies on DBAL (but I might be wrong, ofc).

@ionuttocila ionuttocila reopened this Oct 23, 2017
Base automatically changed from master to 4.0.x January 22, 2021 07:43
@morozov morozov closed this Oct 26, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants