{"action":"created","issue":{"url":"https://api.github.com/repos/shipperhq/module-shipper/issues/7","repository_url":"https://api.github.com/repos/shipperhq/module-shipper","labels_url":"https://api.github.com/repos/shipperhq/module-shipper/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/shipperhq/module-shipper/issues/7/comments","events_url":"https://api.github.com/repos/shipperhq/module-shipper/issues/7/events","html_url":"https://github.com/shipperhq/module-shipper/issues/7","id":158130749,"number":7,"title":"CarriergroupShippingDetails json decode syntax error","user":{"login":"cheelahim","id":5220855,"avatar_url":"https://avatars.githubusercontent.com/u/5220855?v=3","gravatar_id":"","url":"https://api.github.com/users/cheelahim","html_url":"https://github.com/cheelahim","followers_url":"https://api.github.com/users/cheelahim/followers","following_url":"https://api.github.com/users/cheelahim/following{/other_user}","gists_url":"https://api.github.com/users/cheelahim/gists{/gist_id}","starred_url":"https://api.github.com/users/cheelahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheelahim/subscriptions","organizations_url":"https://api.github.com/users/cheelahim/orgs","repos_url":"https://api.github.com/users/cheelahim/repos","events_url":"https://api.github.com/users/cheelahim/events{/privacy}","received_events_url":"https://api.github.com/users/cheelahim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-02T12:40:00Z","updated_at":"2016-06-07T03:23:41Z","closed_at":"2016-06-02T15:32:38Z","body":"Hello. There is an issue with decoding empty Carriergroup Shipping Details inside the ShippingInformationPlugin::saveCarrierGroupInformation() on PHP7 (Magento 2.0.7 EE) when found rate has 'carriergroup_shipping_details' key set to null.\r\n\r\n1. ShipperHQ\\Shipper\\Helper\\Data::decodeShippingDetails() utilizes Magento Json helper which uses Zend_Json::decode() implementation under the hood.\r\n```\r\n$shipDetails = $this->shipperDataHelper->decodeShippingDetails($foundRate->getCarriergroupShippingDetails());\r\n```\r\n In case php json extension is installed on the host system, json_decode() will be used to decode the shipping details. But, in PHP7 json_decode() will produce a [syntax error](http://php.net/manual/ru/function.json-last-error.php#118165) upon empty string decoding.\r\n\r\nThis issue could be temporary mitigated by setting Zend_Json::$useBuiltinEncoderDecoder to true from outside the method in order to avoid using json_decode(). But this is not a best way to address the issue. \r\n\r\n2. Even if you would manage to decode the shipping details by utilizing Zend_Json::$useBuiltinEncoderDecoder flag you will get NULL which will break the array key check, producing the error: \"Warning: array_key_exists() expects parameter 2 to be array, null given...\"\r\n```           \r\nif(array_key_exists('carrierGroupId', $shipDetails)) {\r\n    $arrayofShipDetails = array();\r\n    $arrayofShipDetails[] = $shipDetails;\r\n    $shipDetails = $arrayofShipDetails;\r\n    $encodedShipDetails = $this->shipperDataHelper->encodeShippingDetails($arrayofShipDetails);\r\n}\r\nelse {\r\n    $encodedShipDetails = $this->shipperDataHelper->encodeShippingDetails($shipDetails);\r\n }\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/shipperhq/module-shipper/issues/comments/224160529","html_url":"https://github.com/shipperhq/module-shipper/issues/7#issuecomment-224160529","issue_url":"https://api.github.com/repos/shipperhq/module-shipper/issues/7","id":224160529,"user":{"login":"wsagen","id":4350893,"avatar_url":"https://avatars.githubusercontent.com/u/4350893?v=3","gravatar_id":"","url":"https://api.github.com/users/wsagen","html_url":"https://github.com/wsagen","followers_url":"https://api.github.com/users/wsagen/followers","following_url":"https://api.github.com/users/wsagen/following{/other_user}","gists_url":"https://api.github.com/users/wsagen/gists{/gist_id}","starred_url":"https://api.github.com/users/wsagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wsagen/subscriptions","organizations_url":"https://api.github.com/users/wsagen/orgs","repos_url":"https://api.github.com/users/wsagen/repos","events_url":"https://api.github.com/users/wsagen/events{/privacy}","received_events_url":"https://api.github.com/users/wsagen/received_events","type":"User","site_admin":false},"created_at":"2016-06-07T03:23:41Z","updated_at":"2016-06-07T03:23:41Z","body":"This is included in release version 20.0.6"}}
{"actor":{"display_login":"wsagen"}}