Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if download_id exists before using #8181 #8182

Merged
merged 1 commit into from
Nov 2, 2020
Merged

Conversation

ashleyfae
Copy link
Contributor

Fixes #8181

Proposed Changes:

  1. Check if download_id key exists before using.
  2. Only add item to cart if $download_id isn't empty.
  3. Don't save edd_add_to_cart() output to a variable, as the variable is never used.

I opted to continue the flow of the function instead of bailing immediately, because that way you'll still get redirected to checkout, even though your cart is empty. I thought this might make it easier to debug a broken URL.

To test:

  1. Manually visit a malformed add to cart URL like this: https://yoursite.com/checkout/?edd_action=add_to_cart . Ensure you are redirected to checkout with no items in your cart. Ensure no PHP notices.
  2. Manually visit a correctly formed add to cart URL like this: https://yoursite.com/checkout/?edd_action=add_to_cart&download_id=123 (replace 123 with ID of a valid download). Ensure you are redirected to checkout with that item in your cart.

Copy link
Contributor

@robincornett robincornett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • tested with incomplete URL (missing download_id)
  • tested with valid download_id
  • tested with invalid download_id

Copy link
Contributor

@LisaCee LisaCee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Replicated error in debug log on release/3.0 with missing download_id

  • No error on this branch

  • Item added to cart with valid download_id, no error

  • No item added to cart with invalid download_id, no error

@ashleyfae ashleyfae merged commit 0733860 into release/2.10 Nov 2, 2020
@ashleyfae ashleyfae deleted the issue/8181 branch November 2, 2020 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible to get "Undefined index: download_id" error from malformed "add to cart" URL
3 participants