On edit shipment (e.g. /admin/commerce/orders/X/shipments/XX/edit) there is an infinite loop caused by CurrencyHelper::isAdminOrder().
What happened:
1. CurrencyOrderRefresh::checkCurrency event subscriber ORDER_LOAD is leading to CurrencyHelper::isAdminOrder() check
2. CurrencyHelper::isAdminOrder() loads order again from route param triggering CommerceContentEntityStorage::postLoad() that dispatches ORDER_LOAD event again in loop
as a result You get 'Error: Maximum function nesting level of '256' reached, aborting! in is_array()'.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff-13-15.txt | 9.22 KB | valic |
| #15 | 3150116-15.patch | 36.77 KB | valic |
| #13 | interdiff-11-13.txt | 456 bytes | valic |
| #13 | 3150116-13.patch | 29.31 KB | valic |
| #11 | 3150116-11.patch | 30 KB | valic |
Comments
Comment #2
agolubic commentedComment #3
valicThis is introduced in 3099944 because the order object is not available, but order id in some cases.
I see that commerce_shipment is extending admin route providers now, and therefor shipment edit form is admin route.
Think it was not before when have chosen to go with the current approach.
This needs to be completely removed, and for any check on admin we should take into consideration only the admin path defined by routes, it is most cleanest way to do it.
There is no point in adding more specific checks for each case
Comment #4
sorabh.v6Hi,
I used the $order we get in the CurrencyOrderRefresh event subscriber class. Its working on my local, and it doesn't use the database query directly.
Please check and give feedback, if any.
Thanks
Comment #5
sorabh.v6Comment #6
sorabh.v6Hi,
Previous patch is missing one check, added that in this new patch.
Thanks
Comment #7
valicThere is a simpler way it seems to fix this
Comment #8
valicAdjusting the title to more reflect upcoming patch
Comment #9
valicComment #10
valicComment #11
valicInitial patch attached.
There were a few more changes, but added test coverage for commerce admin orders and shipment admin handling.
We in fact are running core tests, wrapped with injected different currentCurrency than core tests.
That should confirm that we are not influencing any admin CRUD action.
So three tests cases are still going to fail
Comment #13
valicRemoving some debug lines from shipping. (that is the reason for failing those)
Now we are down to two failing tests from core
Comment #15
valicNeeded to rework path changes, it seems for now it is easiest just ignore /admin completely.
Until 2.x overall rewrite, this ought to be enough.
With core commerce/shipping tests passing with injected different current currency value.
Comment #16
valicNice!
All tests are passing, ours for cart/checkout, and core commerce/shipping for creating orders/shipments through admin UI with injected different currentCurrency.
Most definitely committing this today 🥳 .
Comment #18
valicCommitted.
This is the last big change before moving to 2.x version of the module
2.x plan