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

MAGETWO-81311: Check the length of the array before attempting to sli… #11637

Merged
merged 3 commits into from
Oct 26, 2017

Conversation

briscoda
Copy link

@briscoda briscoda commented Oct 23, 2017

…ce it. Slicing an array of one will create an empty result. Issue: 9944

Description

#9944

In the UI form element abstract.js, there is a case where the dataScope passed to the initConfig function may not have the string "data" appended to the name. In this case, performing a 'slice' on an array of 1 will create an empty result. In these cases, I have added a check to ensure that the array is at least greater than 1 before slicing, otherwise, use the result of splitting the scope variable.

In these cases you will always end of with something like:
["data_value"] or ["data_value", "data_value_two"]

Instead of a potential: [], which when used as the inputName would result in an empty input name attribute on the form element.

Fixed Issues (if relevant)

  1. Name attribute shows empty when creating custom fields on product creation form #9944: Name attribute shows empty when creating custom fields on product creation form

Manual testing scenarios

  1. Open the original Issue (Name attribute shows empty when creating custom fields on product creation form #9944)
  2. Create a module with a product_form.xml ui component
  3. Use a fieldname as a single string. (ie "placeholder")
  4. View the field in the product create form and ensure that there is an html name element with the same value that is in the product_form.xml

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)

…ce it. Slicing an array of one will create an empty result. Issue: 9944
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Oct 23, 2017

CLA assistant check
All committers have signed the CLA.

@@ -119,7 +119,7 @@ define([
this._super();

scope = this.dataScope;
name = scope.split('.').slice(1);
name = scope.split('.').length > 1 ? scope.split('.').slice(1) : scope.split('.');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think would be great to extract scope.split('.') to variable in order not to calculate it 3 times

…. scope variable is not used anywhere else except on the next line. Issue: 9944
@ishakhsuvarov ishakhsuvarov self-assigned this Oct 23, 2017
@ishakhsuvarov ishakhsuvarov added this to the October 2017 milestone Oct 23, 2017
@ishakhsuvarov ishakhsuvarov added Release Line: 2.2 2.2.x Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 23, 2017
@magento-team magento-team merged commit 08c61ac into magento:2.2-develop Oct 26, 2017
magento-team pushed a commit that referenced this pull request Oct 26, 2017
magento-team pushed a commit that referenced this pull request Oct 26, 2017
[EngCom] Public Pull Requests - 2.2-develop
 - MAGETWO-82724 Allow coupon code with special charater to be applied to order in checkout #11710
 - MAGETWO-82675 Add a health check to the NGINX configuration sample #11690
 - MAGETWO-82562 Coupon codes not showing in invoice #11635
 - MAGETWO-82535 Fixed ability to set field config from layout xml #11302 [backport 2.2] #11643
 - MAGETWO-81146 Fixing #10275 keyboard submit of adminhtml suggest form. #11250
 - MAGETWO-82761 [Backport 2.2-develop] Dashboard Fix Y Axis for range #11751
 - MAGETWO-82748 Fix Notice: freePackageValue is undefined #11720
 - MAGETWO-82747 [TASK] Updated user.ini according to Magento DevDocs #11734
 - MAGETWO-82537 MAGETWO-81311: Check the length of the array before attempting to sli… #11637
 - MAGETWO-81970 Add missing translations in Magento_UI #11440
 - MAGETWO-81904 FIX #11022 in 2.2-develop: Filter Groups of search criteria parameter have not been included for further processing #11421
 - MAGETWO-82179 Fix Filter Customer Report Review 2.2-develop [Backport] #11522
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Progress: accept Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants