postnl / postnl-magento2

This is the official Magento 2 extension for the logistics company PostNL. Add shipping options and parcelshops to your checkout. Create labels with track and trace functionality from the backend.
58 stars 60 forks source link

[BUG] Passing null to parameter #1 of type string is deprecated in Plugin/Shipment/ShippingBuilder.php on line 37 #385

Open DuckThom opened 2 weeks ago

DuckThom commented 2 weeks ago

To Reproduce Steps to reproduce the behavior:

  1. Have an order without a shipping method (Not fully sure how to create such an order, but the order causing the issue on our side has the status 'cancelled' plus the field can be null in the database)

Expected result No exception is thrown

Actual result

An exception is thrown and the GraphQL query is aborted

[2024-07-03T09:02:50.017338+00:00] report.ERROR: Deprecated Functionality: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /data/web/uat_magento_2/vendor/tig/postnl-magento2/Plugin/Shipment/ShippingBuilder.php on line 37

GraphQL (30:13)
29:         customer {
30:             orders(pageSize: $pageSize, currentPage: $currentPage) {
                ^
31:                 total_count
 [] []

Workaround

Manually updating/patching the following line to cast $method to a string

https://github.com/postnl/postnl-magento2/blob/1e8f126ea3e3062cfbbc592c43fd1eb640592c8b/Plugin/Shipment/ShippingBuilder.php#L37

Screenshots

image image

Please complete the following information

downforce80 commented 2 weeks ago

We had the same issue when creating a magento admin order in the backend with shipping method postNL.

Magento ver. 2.4.4-p9 PostNL version: 1.15.2