magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

M2.2.3 directory_country_region_name locale fix? 8bytes zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes) #14001

Closed jiyun closed 4 years ago

jiyun commented 6 years ago

Preconditions

Perhaps it is English, French, German, Italian and so Latin. Shorthand notation is short (en_US 5 bytes) The various dialects of Chinese are limited by the length of the field? zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes)

directory_country_region_name locale 8bytes

Steps to reproduce

zh_Hans_CN” ->directory_country_region_name locale == “zhHans” Invalid after restricted character truncation

Problem path: app/code/Magento/Directory/Setup/InstallSchema.php:143

        $table = $installer->getConnection()->newTable(
            $installer->getTable('directory_country_region_name')
        )->addColumn(
            'locale',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            8,
            ['nullable' => false, 'primary' => true, 'default' => false],
            'Locale'

Expected result

Change to 14 known valid byte or 16? or only 11 bytes of Chinese zh_hans_xx

Just change it. We are doing Chinese localization Magento2 will be convenient for many

Actual result

New additional data app/code/Magento/Directory/Setup/InstallSchema.php

//中国省级地址
        $datacn = [
            ['CN','11','BJ','京','Beijing','北京市'],
            ['CN','12','TJ','津','Tianjing','天津市'],
            ['CN','13','HE','冀','Hebei','河北省'],
            ['CN','14','SX','晋','Shanxi','山西省'],
            ['CN','15','NM','蒙','Inner Mongoria','内蒙古自治区'],
            ['CN','21','LN','辽','Liaoning','辽宁省'],
            ['CN','22','JL','吉','Jilin','吉林省'],
            ['CN','23','HL','黑','Heilongjiang','黑龙江省'],
            ['CN','31','SH','沪','Shanghai','上海市'],
            ['CN','32','JS','苏','Jiangsu','江苏省'],
            ['CN','33','ZJ','浙','Zhejiang','浙江省'],
            ['CN','34','AN','皖','Anhui','安徽省'],
            ['CN','35','FJ','闽','Fujian','福建省'],
            ['CN','36','JX','赣','Jiangxi','江西省'],
            ['CN','37','SD','鲁','Shandong','山东省'],
            ['CN','41','HA','豫','Henan','河南省'],
            ['CN','42','HB','鄂','Hubei','湖北省'],
            ['CN','43','HN','湘','Hunan','湖南省'],
            ['CN','44','GD','粤','Guangdong','广东省'],
            ['CN','45','GX','桂','Guangxi','广西壮族自治区'],
            ['CN','46','HI','琼','Hainan','海南省'],
            ['CN','50','CQ','渝','Chongqing','重庆市'],
            ['CN','51','SC','川','Sichuan','四川省'],
            ['CN','52','GZ','贵','Guizhou','贵州省'],
            ['CN','53','YN','云','Yunnan','云南省'],
            ['CN','54','XZ','藏','Tibet','西藏自治区'],
            ['CN','61','SN','陕','Shaanxi','陕西省'],
            ['CN','62','GS','甘','Gansu','甘肃省'],
            ['CN','63','QH','青','Qinghai','青海省'],
            ['CN','64','NX','宁','Ningxia','宁夏回族自治区'],
            ['CN','65','XJ','新','Xinjiang','新疆维吾尔自治区'],
            ['CN','71','TW','台','Taiwan','台湾省'],
            ['CN','81','HK','港','Hong Kong','香港特别行政区'],
            ['CN','82','MO','澳','Macao ','澳门特别行政区']
//ISO标准国家缩写0,国标省级数字编码1,国标省级域名缩写2,国标省级单字缩写(车牌)3,国标省级英文4,国标省级全称5。
        ];
        foreach ($datacn as $row) {
            $bind = ['country_id' => $row[0], 'code' => $row[2], 'default_name' => $row[4]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
            $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
            $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[4]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
            $bind = ['locale' => 'zh_Hans_CN', 'region_id' => $regionId, 'name' => $row[5]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
        }

Error effect 1

Before Database pic 1 2

Target effect 2

Modified After Database pic 3 4

jiyun commented 6 years ago

Error effect 1

Before Database pic 1 2

Target effect 2

Modified After Database pic 3 4

magento-engcom-team commented 6 years ago

@jiyun, thank you for your report. We've acknowledged the issue and added to our backlog.

m2-assistant[bot] commented 4 years ago

Hi @engcom-Echo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Echo Thank you for verifying the issue. Based on the provided information internal tickets MC-30122 were created

Issue Available: @engcom-Echo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

VladimirZaets commented 4 years ago

Hi @jiyun. Thank you for your report. The issue has been fixed in magento/magento2#26268 by @Bartlomiejsz in 2.4-develop branch Related commit(s):

The fix will be available with the upcoming 2.4.0 release.