Skip to content

Fix nullable return in getUserIdentifier() when username is not set#1140

Open
Dylvn wants to merge 1 commit intooroinc:6.1from
Dylvn:patch-1
Open

Fix nullable return in getUserIdentifier() when username is not set#1140
Dylvn wants to merge 1 commit intooroinc:6.1from
Dylvn:patch-1

Conversation

@Dylvn
Copy link
Copy Markdown

@Dylvn Dylvn commented Apr 17, 2026

Fixes oroinc/customer-portal#14

Problem

When importing CustomerUser records without an ID (creation) and without an email address, a TypeError is triggered during Symfony validation.

The validator calls __toString() on the freshly instantiated entity, which internally calls getUserIdentifier():

public function __toString()
{
    return (string)$this->getUserIdentifier();
}

The (string) cast never executes. The TypeError is raised inside getUserIdentifier() itself, before the cast can apply.

Root cause

$username is declared as ?string at the Doctrine level, which is a valid state during entity construction (e.g. import processing before the field is hydrated). However, Symfony's UserInterface contract enforces a strict string return type on getUserIdentifier().

Fix

Return an empty string as fallback to bridge the gap between the nullable Doctrine mapping and the strict Symfony interface contract.

@mbessolov
Copy link
Copy Markdown
Member

Thank you for your pull request.

It looks like this may be your first contribution to an Oro, Inc. open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://oroinc.com/b2b-ecommerce/contributor-license-agreement/

If you've already signed the CLA, it's possible we don't have your GitHub username or you're using a different email address. GitHub uses the email address you set in your local Git configuration to associate commits with your GitHub account. Please sign the CLA again using the correct GitHub username and email address or see this help article on setting the email on your git commits.

Once you've signed the CLA, please allow for some time for the submission to be processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants