Repository navigation
Save Manual Capture dependent config in the scope of the field - #6
Open
lbajsarowicz wants to merge 1 commit into
Open
lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
ManualCapture::saveValue() passed no scope to the config writer, so payment_action and the *_recurring and *_vault manual_capture values were always written to the default scope, even when the field was saved for a website or store. Pass the scope and scope id of the field, as Vault does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Manual Capture field of the credit card, Visa, Mastercard and Maestro gateways is available in website and store scope, but
ManualCapture::saveValue()calls the config writer without a scope. The dependentpayment_actionvalue and the*_recurringand*_vaultmanual_capturevalues are therefore always written to the default scope, so toggling Manual Capture for one website changes the payment action for every website.Fix
saveValue()passes$this->getScope()and$this->getScopeId()to the writer, the same wayVault::afterSave()already does.ManualCapturealso gets anafterDelete()that removes the dependent rows from the website or store scope when the field is set back to "Use Default", so they do not stay behind and keep authorizing only.Why this approach
The backend model is saved with the scope of the field being edited, so reusing that scope keeps the dependent values next to the field that triggered them and needs no new state or configuration.
Upgrade note
Shops that already saved Manual Capture at website or store scope on 4.4.1 or older still have
payment_action,*_recurringand*_vaultrows in the default scope that affect every website. Re-save the setting at the intended scope to correct them. This PR contains no migration.Test plan
testAfterSaveWritesAtTheScopeOfTheField,testAfterSaveWritesAtTheDefaultScope,testAfterDeleteRemovesDependentValuesFromTheScopeandtestAfterDeleteKeepsDefaultScopeValuestoTest/Integration/Model/Config/Backend/ManualCaptureTest.php.'websites'expected,'default'written) and all 8 tests pass after it.phpcswith the repositoryphpcs.xmlreports no violations on the changed files.bin/magento setup:di:compileandsetup:static-content:deploy -f en_USon Magento Open Source 2.4.9 / PHP 8.5 with this branch installed: both pass.