-
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
[backport 2.2] Magento 2 Store Code validation regex: doesn't support uppercase letters in store code #12011
[backport 2.2] Magento 2 Store Code validation regex: doesn't support uppercase letters in store code #12011
Conversation
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.
For consistent behavior please provide also similar changes in the \Magento\Store\Model\ResourceModel\Website::_beforeSave
@@ -463,10 +463,10 @@ protected function _getValidationRulesBeforeSave() | |||
$storeLabelRule->setMessage(__('Name is required'), \Zend_Validate_NotEmpty::IS_EMPTY); | |||
$validator->addRule($storeLabelRule, 'name'); | |||
|
|||
$storeCodeRule = new \Zend_Validate_Regex('/^[a-z]+[a-z0-9_]*$/'); | |||
$storeCodeRule = new \Zend_Validate_Regex('/^[a-zA-Z]+[a-z0-9_]*$/'); |
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.
This expression will not allow code with uppercase letter after number or underscore (e.g. a1A
). Instead of modifying regexp it's better to apply modifier i
(PCRE_CASELESS) to make case-insensitive comparison.
$storeCodeRule->setMessage( | ||
__( | ||
'The store code may contain only letters (a-z), numbers (0-9) or underscore (_),' | ||
'The store code may contain only letters (a-zA-Z), numbers (0-9) or underscore (_),' |
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 do not modify the description as this will break existed translations (will be backward incompatible change). As string does not say "lowercase letters" it is also applicable for updated implementation
@vkublytskyi @magento-engcom-team any idea why this is needed? For codes, like store code, website code, attribute code, to keep things consistent and avoid accidental mistake in character case it is much better to have them in |
…doesn't support uppercase letters in store code #12011
[EngCom] Public Pull Requests - 2.2-develop - MAGETWO-83278: Add validation for number of street lines #12013 - MAGETWO-83277: [backport 2.2] Magento 2 Store Code validation regex: doesn't support uppercase letters in store code #12011 - MAGETWO-82991: Product attribute creation page handles Storefront tab visibility wrong #11770 - MAGETWO-82976: Update wrong layout update xml handle installed in CMS Home Page by d… #11863 - MAGETWO-82952: Check attribute unique between same fields in magento commerce #11620
Description
Magento 2 Store Code validation regex: doesn't support uppercase letters in store code
Fixed Issues (if relevant)
Contribution checklist