Problem/Motivation

When Layout builder is enabled and a Phone field is formatted using Whatsapp Formatter, it fails with:

TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, int given in preg_replace() (line 41 of src/Plugin/Field/FieldFormatter/WhatsappNumberFormatter.php).

Steps to reproduce

- Create a Phone field
- Apply Whatsapp Formatter
- Enable Layout builder in bundle
- Visit Layout builder page

Proposed resolution

Implements casting to the field to be sure is a string

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

aldibier created an issue. See original summary.

aldibier’s picture

Status: Active » Needs review
StatusFileSize
new864 bytes

I've created a Patch and a Pull request to fix this issue, please review

gueguerreiro’s picture

Assigned: aldibier » Unassigned
Status: Needs review » Fixed

Thanks! Merged and included in the new 1.0.3 release.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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