Skip to content

Customer group code saved does not match the input when using multibyte characters #39342

Open
@oskar-olaussen

Description

@oskar-olaussen

Preconditions and environment

  • Magento version: tested on 2.4.7-p3.
  • Copypasteble 31 "ö" characters for convenience: ööööööööööööööööööööööööööööööö

Steps to reproduce

  1. In admin go to Customer->Customer Groups.
  2. Click "Add New Customer Group"
  3. Input 31 "ö" characters as the group name:
    Screenshot from 2024-11-07 16-35-27
  4. Click "Save Customer Group".

Expected result

A customer group with code "ööööööööööööööööööööööööööööööö" is created.

Actual result

A customer group with code "öööööööööööööööö" (16 characters) is created.

Additional information

The issue is most likely in these two places:

$this->setCode(substr($this->getCode(), 0, self::GROUP_CODE_MAX_LENGTH));
and
$group->setCode(substr($group->getCode(), 0, $group::GROUP_CODE_MAX_LENGTH));
.

There we are using the substr function instead of mb_substr. I see no issue with using mb_substr as the database can handle 32 multibyte characters fine.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: AccountComponent: CustomerIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.7-p3Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions