Skip to content

Braintree Paypal Review: check if variable is array when validating request data #18614

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

Merged
merged 3 commits into from
Oct 25, 2018

Conversation

deninchoo
Copy link
Contributor

@deninchoo deninchoo commented Oct 15, 2018

Description (*)

In some cases when the Magento/Braintree/Paypal/Review.php class gets executed, the $requestData = json_decode( $this->getRequest()->getPostValue('result', '{}'), true ); does not get declared as an array as the requested post value returns a null, causing the validateRequestData($requestData) function call to produce the TypeError: Uncaught exception as the function expects the passed variable $requestData to be an array.

This pull request introduces changes that ensure there are no exceptions when a null value is passed to the validateRequestData($requestData) function.

Fixed Issues (if relevant)

  1. n/a

Manual testing scenarios (*)

  1. n/a

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @deninchoo. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team
Copy link
Contributor

@deninchoo thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

*/
private function validateRequestData(array $requestData)
private function validateRequestData($requestData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of changing this function, please fix a place where it is called

does not get declared as an array as the requested post value returns a null, causing the validateRequestData($requestData)

Copy link
Contributor

@rogyar rogyar Oct 15, 2018

Choose a reason for hiding this comment

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

Not sure it's the best way to go. It's a private method and its purpose is to validate the request data. So, checking the type might be a part of the validation. It looks like an overhead to create an additional validation alongside with the method-validator.

@orlangur orlangur self-assigned this Oct 15, 2018
@magento-engcom-team magento-engcom-team merged commit 06237d6 into magento:2.3-develop Oct 25, 2018
magento-engcom-team pushed a commit that referenced this pull request Oct 25, 2018
@magento-engcom-team
Copy link
Contributor

Hi @deninchoo. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants