Skip to content

Commit

Permalink
MAGETWO-83319: [backport 2.1] Magento 2 Store Code validation regex: …
Browse files Browse the repository at this point in the history
…doesn't support uppercase letters in store code #12040
  • Loading branch information
ishakhsuvarov authored Nov 6, 2017
2 parents 264a59a + cc56c4d commit 79f9c76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Store/Model/ResourceModel/Website.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function readAllWebsites()
->select()
->from($this->getTable('store_website'));

foreach($this->getConnection()->fetchAll($select) as $websiteData) {
foreach ($this->getConnection()->fetchAll($select) as $websiteData) {
$websites[$websiteData['code']] = $websiteData;
}

Expand All @@ -63,7 +63,7 @@ public function readAllWebsites()
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
if (!preg_match('/^[a-z]+[a-z0-9_]*$/i', $object->getCode())) {
throw new \Magento\Framework\Exception\LocalizedException(
__(
'Website code may only contain letters (a-z), numbers (0-9) or underscore (_),'
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Store/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use Magento\Framework\App\Http\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ScopeInterface as AppScopeInterface;
use Magento\Framework\Filesystem;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
use Magento\Framework\Filesystem;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
use Magento\Framework\UrlInterface;
use Magento\Store\Api\Data\StoreInterface;

Expand Down Expand Up @@ -459,7 +459,7 @@ 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-z]+[a-z0-9_]*$/i');
$storeCodeRule->setMessage(
__(
'The store code may contain only letters (a-z), numbers (0-9) or underscore (_),'
Expand Down

0 comments on commit 79f9c76

Please sign in to comment.