-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
AttributeCode column name length validation throws wrong error message #20766 #20767
AttributeCode column name length validation throws wrong error message #20766 #20767
Conversation
Hi @irajneeshgupta. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@irajneeshgupta could you tell me the reason why the attribute code is restricted to 30 chars? would further be an input validation within the backend form be useful? |
yes , input validation max-30 will be useful , i think I will update my commit. Thanks @brosenberger |
@irajneeshgupta in my case 30 characters are not enough as i am a bit bound by external system constraints for a customer project :-( |
https://magento.stackexchange.com/questions/7491/why-do-attribute-codes-have-a-maximum-length |
@irajneeshgupta according to that comment all oracle versions equals and below 12.1 are effected - but neither version of oracle is officially supported by magento 2.3: https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html#database though there is a constraint on mysql column name lengths of 64 characters (https://dev.mysql.com/doc/refman/8.0/en/identifiers.html) which should be used instead a comment within the code why X characters are allowed would be nice in every case |
@@ -203,7 +203,8 @@ public function execute() | |||
$this->messageManager->addErrorMessage( | |||
__( | |||
'Attribute code "%1" is invalid. Please use only letters (a-z or A-Z), ' . | |||
'numbers (0-9) or underscore(_) in this field, first character should be a letter.', | |||
'numbers (0-9) or underscore(_) in this field, first character should be a letter, ' . | |||
'and length should be less than 30 characters.', |
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.
Please make a separate check for length which appears earlier than this.
Also, 30 chars seems to be allowed from regexp.
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.
@orlangur sir
sure i am adding it.
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.
@orlangur sir ,
i have added seperate length check before string validation.
$validatorAttrCode = new \Zend_Validate_Regex(
['pattern' => '/^[a-zA-Z\x{600}-\x{6FF}][a-zA-Z\x{600}-\x{6FF}_0-9]{0,30}$/u']
);
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.
@orlangur
sir, please review the changes.
Thank you.
@orlangur Hi, I too issue some time due to the length limit of
|
@milindsingh, nope, there could be a lot of stuff tied to it.
|
5926b55
to
299ab72
Compare
@orlangur any comments to my follow up links why 30 characters are not a hard constraint because of the old oracle version and reference to magento 1.6? |
@brosenberger thanks for pointing out, I found that I already talked on this with Olexii in #10225 (comment). Looks like this one is just a legacy check in Catalog module not in sync with others, I'll check soon and give exact direction to PR author. |
@orlangur sir, In this PR that you referenced #10225 Should i change the string validation to 60 chars. since it is currently checking for 30 chars. |
@orlangur sir, |
@@ -210,7 +212,7 @@ public function execute() | |||
} | |||
if (strlen($attributeCode) > 0) { | |||
$validatorAttrCode = new \Zend_Validate_Regex( | |||
['pattern' => '/^[a-zA-Z\x{600}-\x{6FF}][a-zA-Z\x{600}-\x{6FF}_0-9]{0,30}$/u'] | |||
['pattern' => '/^[a-zA-Z\x{600}-\x{6FF}][a-zA-Z\x{600}-\x{6FF}_0-9]{0,60}$/u'] |
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.
when using the constant above for checking the length, it should be included here as well for the regexp (to be sure if it changes in future and not have failing this constraint which was already checked previously)
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.
@brosenberger
you are correct , let me add maxLength i.e, 60 in regex
1bb907f
to
5a9a9e6
Compare
Hi @irajneeshgupta can you please check #20526 I believe it resolves the issue. Let's close this pull request as a duplicate and collaborate to deliver #20526 |
@sivaschenko |
Hi @irajneeshgupta, thank you for your contribution! |
#20766
Description (*)
Attribute length
30 char
check and error message added.Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)