Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions Are Silently Dropped #183

Open
kiler129 opened this issue Jun 7, 2018 · 4 comments
Open

Extensions Are Silently Dropped #183

kiler129 opened this issue Jun 7, 2018 · 4 comments

Comments

@kiler129
Copy link

kiler129 commented Jun 7, 2018

Problem

While working with phone numbers I discovered that phone numbers aren't handled properly when they contain extension. This is related to giggsey/libphonenumber-for-php#255, since PhoneNumberType internally calls PhoneNumberUtil::format() while saving and PhoneNumberUtil::parse() while reading.

Solution

Maybe a better way would be to serialize and unserialize the object instead to prevent loosing data, since PhoneNumber intentionally implements \Serializable. Of course at this point it has to be done as a separate DBAL type to prevent BC issues with old data saved in DB.

I can prepare patch if you like, however I'm not sure is that what you want to do.

Workaround

Currently the easiest workaround for the issue while using anemic entities is to use two fields in entity, say phone & phoneExt and make getPhone() add extension to the object from phoneExt() and setPhone() to extract extension to a separate field.

@gnat42
Copy link

gnat42 commented Oct 1, 2018

Why not store the PhoneNumberFormat::RFC3966 ? This stores the extension as well. Is there data it loses compared to E164? I'm wondering if we could even configure the doctrine type to allow us to pick the DB format?

@kiler129
Copy link
Author

kiler129 commented Oct 1, 2018

@gnat42 Mostly useless overhead of tel:. However we actually did that and we store RFC-3966 format with custom doctrine type. We can strip tel: on conversion, but we don't do that to make stuff more standarized.

@gnat42
Copy link

gnat42 commented Oct 1, 2018

Yeah, I've just done the same thing locally.

@webmasterMeyers
Copy link

I have also discovered this issue. This is on a brand new setup, so BC is not an issue.

when you say to use "setPhone() to extract extension to a separate field." do you mean in the entity? Do you have a code example of the getter and setter methods you use for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants