Cart applied_taxes of empty cart causes 'Internal server error' message on PHP 7.2
therealtbs opened this issue · 2 comments
therealtbs commented
Preconditions (*)
- PHP 7.2.18
- Magento 2.3.2
Steps to reproduce (*)
- Create an empty cart
mutation {
createEmptyCart
}
- Retrieve that cart without adding any products
{
cart(cart_id: "CARTID") {
prices {
grand_total {
value
}
applied_taxes {
amount {
value
}
}
}
}
}
Expected result (*)
{
"data": {
"cart": {
"prices": {
"grand_total": {
"value": 0
},
"applied_taxes": []
}
}
}
}
Actual result (*)
{
"errors": [
{
"debugMessage": "Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vendor/magento/module-quote-graph-ql/Model/Resolver/CartPrices.php on line 75",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"cart",
"prices"
]
}
],
"data": {
"cart": {
"prices": null
}
}
}
At this point $appliedTaxes is NULL and therefore not countable. From PHP 7.2 onwards there is a warning generated which I assume Magento turns into a Throwable.
Since the fix is quite easy I'm not sure if I should make a PR for this.
pmclain commented
@therealtbs thanks for pointing out. Would you like to submit a PR to fix? If not I can this weekend.
therealtbs commented
Sure, I'll get it going first thing tomorrow.