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

Fix $attributes default value #21064

Merged
merged 6 commits into from Aug 20, 2019
Merged

Fix $attributes default value #21064

merged 6 commits into from Aug 20, 2019

Conversation

jlnarvaez
Copy link
Contributor

Description (*)

The method $this->getStringCustomAttributes($attributes) causes Exception when $attributes value is null.
I think that default value for $attributes must be empty array because inside of getStringCustomAttributes() will try to do a foreach to a null value.

Fixed Issues (if relevant)

$attributes default value now is empty array

Manual testing scenarios (*)

  1. Inject ImageFactory in your construct method
  2. Try to do $this->imageFactory->create($product, $imageId)
  3. Will cause Exception

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-cicd2
Copy link
Contributor

magento-cicd2 commented Feb 8, 2019

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @jlnarvaez. 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 2.3-develop instance - deploy vanilla Magento instance

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

@ghost ghost assigned sidolov Jun 19, 2019
If $attributes value is null, we convert to empty array to prevent that loop causes Exception.
@jlnarvaez jlnarvaez requested a review from sidolov July 1, 2019 09:01
Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Hi @jlnarvaez thanks for updates, please see my review comments

@@ -76,6 +76,7 @@ public function __construct(
private function getStringCustomAttributes(array $attributes): string
Copy link
Member

Choose a reason for hiding this comment

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

I think the array restriction will result in the TypeError if the $attributes is null.
So I think the code ensuring $attributes is an array should be executed before calling this function

@ghost ghost assigned sivaschenko Jul 5, 2019
Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for update @jlnarvaez ! Finally, could you take a look at the failed static test

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-5434 has been created to process this Pull Request
✳️ @sivaschenko, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@sidolov sidolov added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Jul 15, 2019
@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-5434 has been created to process this Pull Request

@engcom-Delta engcom-Delta self-assigned this Jul 16, 2019
@jlnarvaez jlnarvaez requested a review from orlangur July 22, 2019 07:44
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-5434 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

Hi @jlnarvaez with new changes if I do $this->imageFactory->create($product, $imageId), I got broken page(in my case catalog page) where image should be loaded.
#21064PRBrokenPage
Could you take a look?

This cast causes Exception sometimes cause $attributes value must be "string" instead of null, and then we need to check if value is null.
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-5434 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented Aug 20, 2019

Hi @jlnarvaez, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants