Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Cart applied_taxes of empty cart causes 'Internal server error' message on PHP 7.2 #758

Closed
therealtbs opened this issue Jun 27, 2019 · 2 comments

Comments

@therealtbs
Copy link

Preconditions (*)

  1. PHP 7.2.18
  2. Magento 2.3.2

Steps to reproduce (*)

  1. Create an empty cart
mutation {
  createEmptyCart
}
  1. 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
Copy link
Contributor

pmclain commented Jun 27, 2019

@therealtbs thanks for pointing out. Would you like to submit a PR to fix? If not I can this weekend.

@therealtbs
Copy link
Author

Sure, I'll get it going first thing tomorrow.

therealtbs pushed a commit to therealtbs/graphql-ce that referenced this issue Jun 28, 2019
therealtbs pushed a commit to therealtbs/graphql-ce that referenced this issue Jun 30, 2019
therealtbs pushed a commit to therealtbs/graphql-ce that referenced this issue Jun 30, 2019
therealtbs pushed a commit to therealtbs/graphql-ce that referenced this issue Jun 30, 2019
magento-engcom-team added a commit that referenced this issue Jul 24, 2019
…r error' message on PHP 7.2 #759

 - Merge Pull Request #759 from therealtbs/graphql-ce:758-cart-applied_taxes-null
 - Merged commits:
   1. ab2f3de
   2. 0c08e24
   3. 2f766b1
magento-engcom-team pushed a commit that referenced this issue Jul 24, 2019
@naydav naydav added this to the Release: 2.3.3 milestone Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants