postnl-magento2
postnl-magento2 copied to clipboard
[BUG] Passing null to parameter #1 of type string is deprecated in Plugin/Shipment/ShippingBuilder.php on line 37
To Reproduce Steps to reproduce the behavior:
- 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
** Please complete the following information**
- Magento version: 2.4.5-p8
- PHP version: 8.1.18
- TIG PostNL version: 1.15.2
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
We have the same issue for a placed order that have no shipment method selected. By opening the admin it breaks on the strpos.
added a fix in #387
@DuckThom @downforce80 @rbouma Thank you all for bringing this to our attention. We have released a new version of the plug-in which contains a fix for this bug.
Kind regards Joris - PostNL