-
Notifications
You must be signed in to change notification settings - Fork 1
Save transaction data before state change #22
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
Open
BushraAsif
wants to merge
5
commits into
main
Choose a base branch
from
save-transaction-data-before-state-change
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f7181a8
Save transaction data before state change
BushraAsif c49eb52
Update tested version
BushraAsif 2a3a0a2
Update version and release notes
BushraAsif 3a41418
Check sales channel terminal ID as well in PaymentMethodSubscriber
BushraAsif 9b8acf6
Update release notes
BushraAsif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
Is this really necessary?
The way I see it, you just need to insert the custom fields you want to add using the repository:
https://developer.shopware.com/docs/guides/plugins/plugins/framework/custom-field/add-custom-field.html#filling-data-into-custom-fields
Rather than loading all the custom fields, merging them, and then inserting them again.
You risk that if the custom fields is changed while this operation is processing, then you will insert custom fields with an older value (race condition)
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.
@emicha ,
Order
custom_fieldsare stored as JSON, but there is no clear guarantee that writing only part of that JSON will always keep the other existing fields.There is also a Shopware core issue showing that existing custom_fields can be overwritten when a new array is written instead of merging first:
shopware/shopware#9613
We also need this to behave predictably across different Shopware versions used by merchants.
The safest long-term solution would be to use a separate table/entity instead of relying on the order custom_fields JSON. I have created a separate ticket for that:
https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-custom-compl…
So for this change, I think the explicit merge is the safer short-term fix, and the separate entity is the better long-term solution.
Ticket: PL-1598
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.
@BushraAsif The issue you shared seems to be pointing at updating the full user, and not just a field using:
I am not sure what you shared is applicable here. Please discuss with @mateusz and @ovidiu in my absence.
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.
@emicha @ovidiuba the information I shared is not related to the user field, it belongs to the order field. I'm attaching the order details screen for reference. As shown in the screenshot, the
custom_fieldsdata is saved as JSON, which is why I merge the existing data before saving it again.That's why we read custom fields before writing to it, so we don't mess with other plugins saving data to the custom field.
To properly handle the race condition you mentioned, we need to create a custom table according to the Shopware documentation:
https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-custom-complex-data.html
Ticket: PL-1598