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

Craft CMS 2 phone field (PHP 7.3 regex compatibility issue) #115

Open
jamesmacwhite opened this issue Jan 22, 2021 · 0 comments
Open

Craft CMS 2 phone field (PHP 7.3 regex compatibility issue) #115

jamesmacwhite opened this issue Jan 22, 2021 · 0 comments
Labels

Comments

@jamesmacwhite
Copy link

jamesmacwhite commented Jan 22, 2021

Description

I'm aware the Craft 2 version is unlikely to be updated, but a warning for anyone else who may come across this. Since PHP 7.3 preg_quote() will quote the # character which breaks the phone field validation in Sprout Fields, because it adds a backslash before each # and turns the regex into this:

/^\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})\([0-9]{1})$/

You will get the following error:

preg_match(): Compilation failed: unmatched closing parenthesis at offset 11

This is because the regex has been manipulated in a way which is not expected, because the # character did not behave like this previously.

https://www.php.net/manual/en/function.preg-quote.php

Below PHP 7.3 you won't see the problem.

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

No branches or pull requests

2 participants