Craft CMS 2 phone field (PHP 7.3 regex compatibility issue)
Opened this issue · 0 comments
jamesmacwhite commented
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.