woocommerce / woocommerce-paypal-payments

https://wordpress.org/plugins/woocommerce-paypal-payments/
GNU General Public License v2.0
62 stars 47 forks source link

Loading of non-Order as a WC_Order causes warnings and potential data corruption. (3296) #2343

Closed prettyboymp closed 3 months ago

prettyboymp commented 3 months ago

https://github.com/woocommerce/woocommerce-paypal-payments/blob/f53976e9ea5e2c2fabd8878cb48822f81e08a99e/modules/ppcp-wc-gateway/src/Admin/PaymentStatusOrderDetail.php#L41

Orders shouldn't be Instantiated directly and instead should be retrieved through wc_get_order(). When the edit-subscription (from Woo Subscription) page is loaded with this plugin active, the subscription ends up also being loaded via this call. This causes problems with caching implementations because the cached data doesn't necessarily match the format of the data that the Orders Data store is attempting to use - which is now being loaded for this order because of the way it was instantiated.