-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Allow using a separate db connection for Admin #2903
Allow using a separate db connection for Admin #2903
Conversation
Nice, We should ...
|
Seems not to be a BC break. Change branch? |
@@ -201,10 +203,14 @@ protected function _newConnection($type, $config) | |||
*/ | |||
protected function _getDefaultConnection($requiredConnectionName) | |||
{ | |||
$isAdmin = Mage::app()->getStore()->isAdmin(); | |||
$readResource = $isAdmin ? self::DEFAULT_ADMIN_READ_RESOURCE : self::DEFAULT_READ_RESOURCE; | |||
$writeResource = $isAdmin ? self::DEFAULT_ADMIN_WRITE_RESOURCE : self::DEFAULT_WRITE_RESOURCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way the same function can for the same input return a different connection. If you send an email, the store is changed via emulation, probably not beeing Admin anymore? which means that existing transactions are ignored (or changed data from them not available) and, simply said a lot of hard to debug problems
If you need a separate connection for admin, than it makes more sense to use a different Config for the whole request. |
I will check the env variables solution later. For now this is going back to draft. |
Do you have link for that? |
I think this: #643 |
yes, this was the one I had in mind, was not able to find it anymore |
I like this solution more compared to #643, could it be possible to fix the emulation? |
I don't know yet, haven't much time to explore this further. |
When following the way with having a separate connection during the request, you probably need to introduce a state, (which increases the complexity of the class). Also it might make sense to make this configurable and default Off, as its going to double the parallel connections to the database, which might break a lot of closely optimized Setups. |
Description (*)
This PR adds a new feature that allows optionally using separate database connections (
admin_read
andadmin_write
) for the Admin store. This can be desired for many reasons such as limiting the privileges of the frontend connection's db user. By default, these connections inherit the default ones, so they should work out of the box without any configuration.Fixed Issues (if relevant)
Manual testing scenarios (*)
local.xml
and add the following configuration insideconfig/global/resources
element:Test to make sure the Admin area is now using the new connection. In my case, I made it use the database with sample data installed, whereas the frontend was using a clean database.
Contribution checklist (*)