I installed 2.2, and tried to edit a Text field, and entered the 'Validation'page.
I get the following error:
Parse error: syntax error, unexpected T_STATIC, expecting ')' in ..\field_validation\field_validation_extras\plugins\validator\field_validation_date_validator.inc on line 24

The relevant code is:

  const  PATTERN = '/^(\d{4})-(\d{2})-(\d{2})$/';
  
  public function validate() {
    //The logic copied from Symfony\Component\Validator\Constraints\DateValidator
    if (!preg_match(static::PATTERN, $this->value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) {
    ...
CommentFileSizeAuthor
#7 field_validation-static_fix-1875272.patch1.06 KBcr0ss

Comments

johnv’s picture

1. Why is this date-validator invoked on a text field?

2. I don't understand the error in line 24, but line 23 can be simplified:

   public function validate() {
     //The logic copied from Symfony\Component\Validator\Constraints\DateValidator
-    if ($this->value !== '' && !is_null($this->value)) {
+    if (isset($this->value)  ) {
       if (!preg_match(static::PATTERN, $this->value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) {
         $this->set_error();
       }
g089h515r806’s picture

The code was copied from:
Symfony\Component\Validator\Constraints\DateValidator

DrupalDan’s picture

same error. Sub...

GroggySylv’s picture

Also have the problem. Any solution?

g089h515r806’s picture

I have tested it again, it works correctly.
I use PHP 5.3, Apache/2.2.21, WIndows7, MYSQL 5.5.16.

g089h515r806’s picture

Issue summary: View changes

more precise info.

johnv’s picture

I enabled it with 5.2.17 and got the error (with 2.2).
I enabled it with 5.3.9 and got no error (with 2.2).
Is it a PHP-version thing? I use Acquia Dev Desktop on Windows 7.

EDIT Also, i saw that the file 'field_validation_date_validator.inc' is not included in the latest 2.x version.
Is it replaced with 'field_validation_date_range2_validator.inc' ?

cr0ss’s picture

Status: Active » Needs review
StatusFileSize
new1.06 KB

The PATTERN is being declared as constant but for some reason is used as static variable in line 24. Attaching patch which is fixing this.

2pha’s picture

Patch above fixed it for me :)

g089h515r806’s picture

commited

g089h515r806’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

added code for better reference.