Problem/Motivation

While upgrading a dev environment to D9, Commerce 2.31 and Profile 1.6, I bumped into a changed behavior when it comes to profiles without proper labels: while developing a custom module for Commerce, I created some broken profiles without a proper address. As address_line_1 is used as label source on the customer profile type, any listing of these profiles (on /admin/people/profiles for example) gave me an empty "Label" display..

After upgrading the module to 1.6, the behavior changed: instead of displaying an empty label, the following error is thrown:

TypeError: Argument 1 passed to Drupal\profile\Event\ProfileLabelEvent::setLabel() must be of the type string, null given

Manually adding text to column address_address_line1 on the related row in database table profile__address immediately fixed the problem as it gives ProfileLabelEvent::setLabel() a string to work with (editing existing customer profiles via UI can be tricky in Commerce). Alternatively, downgrading the module to version 1.4 also prevents the error to be thrown.

Not marking it as a bug for now as I encountered the issue on an unclean dev environment.

Proposed resolution

Handle an empty label source in a more tolerant way, like it was up to version 1.4. I did not have the time to check on a productive Drupal Commerce environment yet, but I suspect profiles with empty address / label source to be quite common.

Remaining tasks

Create a patch. Review.

User interface changes

None.

API changes

Unsure.

Data model changes

Unsure.

CommentFileSizeAuthor
#2 3313826-2.patch1.59 KBjsacksick

Comments

markusk created an issue. See original summary.

jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

  • jsacksick committed b919838 on 8.x-1.x
    Issue #3313826 by jsacksick, markusk: Empty profile label source results...
jsacksick’s picture

Status: Needs review » Fixed

Committed the patch, will tag a new release as this bug can be annoying.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.