Closed (fixed)
Project:
Webform Validation
Version:
7.x-1.x-dev
Component:
Validation rules
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Jan 2019 at 18:28 UTC
Updated:
3 Jan 2020 at 18:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
liam morlandI just tried it on a test site and it works as expected for me, at least under PHP 5.6. I don't think the PHP version would matter. Please verify that there is not additional whitespace in either the pattern or the test data.
Comment #3
aroseman18 commentedThere is no whitespace in the pattern or data.
The only thing that changed on the site was PHP version so that was my first guess.
Comment #4
liam morlandPlease try changing your PHP version to see if that is actually the problem. You could try to reproduce just the validation snippet on another server; see webform_validation.validators.inc.
Comment #5
liam morlandIs this still a problem?
Comment #6
liam morlandIf this is still a problem please re-open and provide details.
Comment #7
swigle commentedI've got the same issue. Trying to validate a postalcode useing "#### @@" validator.
This always fails.
It's a site of a client and they just started noticing this. We went from php 7.0X to 7.3X last week, but i can't easily change it back to test.
Comment #8
liam morlandI can't reproduce this problem in my test environment on either PHP 5.6 or PHP 7.2. I suggest downgrading PHP to see if that is the problem. Or add debugging code to see why it is failing.
Comment #9
swigle commentedSince i had some spare time, i fired up an old cluster with PHP 7.0.x to test with.
I created a webform with a single textfield, added a pattern validation of "#### @@" and tried to enter data.
On PHP 7.0.x this works as intended; 1234AB doesn't get validated, 1234 AB is valid.
Switching back to our new cluster with PHP 7.3.4, the exact same page doesn't validate 1234AB as well as 1234 AB so the php version would seem the culprit.
Sadly no errors in the logs or in drupal. It would seem the methods used to check the input versus the pattern have changed in this PHP version which results in the validator always returning invalid.
Comment #10
liam morlandIt will take adding some debugging code to see what the difference is.
Comment #11
swigle commentedAny news on this? All pattern validators aren't working for us, which is kinda a pain :)
Comment #12
liam morlandYou could switch to using regex or add some debugging code to try to figure out what is happening.
Comment #13
liam morlandUsing the latest development version of webform_validation, please create a minimal test case.
Comment #14
jay.dansand commentedI just stumbled into this today after we upgraded to PHP 7.3 yesterday. The problem is that
preg_quote()changed behavior in 7.3 and now escapes#to\#. Whenwebform_validation_webform_validation_validate()creates$patternto test the input,#becomes\#becomes\[0-9](instead of[0-9]) and that regex will never match numbers. Attached is a minimal patch that tests the PHP version and de-escapes "#" in the test pattern.Comment #15
liam morlandThanks for the patch. Instead of duplicating the call to str_replace(), have the line with version_compare() return either '#' or '\#' and use that in the str_replace() call.
Comment #16
jay.dansand commentedSure.
Based on priority levels for issues, this should be major. All pattern-based validators using
#are broken for PHP 7.3+ with no warning to admin and obvious disruption for site visitors. Let's just get the fix in. :)Happy holidays!
Comment #18
liam morlandThanks!