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
Fix $attributes default value #21064
Conversation
Hi @jlnarvaez. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
If $attributes value is null, we convert to empty array to prevent that loop causes Exception.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this 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
Hi @sivaschenko, thank you for the review.
|
Hi @sidolov, thank you for the review. |
Hi @sivaschenko, thank you for the review. |
Hi @jlnarvaez with new changes if I do |
This cast causes Exception sometimes cause $attributes value must be "string" instead of null, and then we need to check if value is null.
Hi @sivaschenko, thank you for the review. |
✔️ QA passed |
Hi @jlnarvaez, thank you for your contribution! |
Description (*)
The method
$this->getStringCustomAttributes($attributes)
causes Exception when$attributes
value isnull
.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 (*)
Contribution checklist (*)