-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Null order in Magento\Sales\Block\Order\PrintShipment.php #9830
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
Comments
Hi, @dnadle, please, provide additional details to reproduce this issue, like products in the order, shipment, etc. I've checked on Magento 2.1.6 and there are no any errors in Magento and Apache logs. |
I stepped through the code. The backend is trying to load the "current" order from a registry but the order is null, and this is not checked before the call to order->getRealOrderId() on line 58. The print version of the order is generated anyway and looks correct. So, to reproduce the issue one must figure out why the order retrieved from the registry would be null. Regardless of any specific aspects of the order, calling a function on an object that could be null is bad code. It's a bug and should be fixed. |
I experience the same issue, using Magento 2.1.7. Page URL: /sales/order/print/order_id/123/ |
Internal ticket was created: MAGETWO-69787 |
This has something to do with full page caching. PrintShipment::_prepareLayout() is called 4 times successfully by an execution chain renders the print version of the order correctly. But then it is called again, by a different chain for which the registry is not properly initialized and this _prepareLayout() call exits with the fatal error. I don't yet know what is triggering this second rendering, but if you disable full page caching it does not occur and there is no error message logged. |
This happens because of the incorrect block class definition. The #11631 contains fix for the order items list. Also, it fixes the error mentioned here |
The issue has been fixed in 2.1-develop branch and will be available with next patch release |
@engcom-backlog-nickolas I have this issue on Magento 2.2.5 when built-in Full Page Cache enabled. I re-opened this issue. Could you re-check if you can reproduce this issue? This issue appears when Magento sends AJAX request to backend like this (the same steps to reproduce, but just cancel print dialog and wait few seconds): |
@ihor-sviziev Internal ticket reopened. Thanks for investigation. |
Hi @dnadle. Thank you for your report. The fix will be available with the upcoming 2.2.8 release. |
Hi @dnadle. Thank you for your report. The fix will be available with the upcoming 2.3.1 release. |
Viewing an order in the customer dashboard and clicking the print order link causes the following entry in httpd error_log:
PHP Fatal error: Call to a member function getRealOrderId() on null in /vendor/magento/module-sales/Block/Order/PrintShipment.php on line 58
Preconditions
Magento 2.1.6
Steps to reproduce
Log in as customer, go to Account Dashboard. Click My Orders, choose an order and click View Order, then click Print Order.
Expected result
No error in httpd error_log.
Actual result
The error described above is logged.
The text was updated successfully, but these errors were encountered: