This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
Prevent duplicate IDs on order/refund save #64
Merged
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.
On a few different occasions (#49, #47, #58), users have reported errors similar to:
These errors were the result of
WC_Order_Data_Store_Custom_Table::$creating
not always being set properly, so the plugin would sometimes try toINSERT
rather thanUPDATE
the corresponding database row.Additionally, since the
WC_Order_Refund_Data_Store_Custom_Table
from #52 — which this PR depends upon — was largely copied fromWC_Order_Data_Store_Custom_Table
(I really can't wait until we can use PHP traits in WordPress!), that class would have run into the same issue.This PR simplifies the logic around the data stores'
update_post_meta()
methods, explicitly checking whether or not a corresponding database row exists and, if not, explicitly inserting it. This enables us to remove the less-than-ideal$creating
properties and avoid duplicate IDs.Blocked by #52. Fixes #47, fixes #49.