Calling drush commands produces The following Php errors:

PHP Fatal error:  Declaration of Drupal\field_validation\Form\FieldValidationRuleAddForm::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, ?Drupal\field_validation\FieldValidationRuleSetInterface $field_validation_rule_set = NULL, $field_validation_rule = NULL) must be compatible with Drupal\field_validation\Form\FieldValidationRuleFormBase::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, ?Drupal\field_validation\FieldValidationRuleSetInterface $field_validation_rule_set = NULL, $field_validation_rule = NULL, $field_name = '') in [REDACTED]/modules/contrib/field_validation/src/Form/FieldValidationRuleAddForm.php on line 18
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                                                          [error]
Error: Declaration of Drupal\field_validation\Form\FieldValidationRuleAddForm::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, ?Drupal\field_validation\FieldValidationRuleSetInterface $field_validation_rule_set = NULL, $field_validation_rule = NULL) must be compatible with
Drupal\field_validation\Form\FieldValidationRuleFormBase::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, ?Drupal\field_validation\FieldValidationRuleSetInterface $field_validation_rule_set = NULL, $field_validation_rule = NULL, $field_name = '') in
[REDACTED]/modules/contrib/field_validation/src/Form/FieldValidationRuleAddForm.php, line 18

The same error also happens in FieldValidationRuleEditForm

Comments

mspae created an issue. See original summary.

mspae’s picture

Anonymous’s picture

Just tried out the patch last night and I can confirm that it solves the issue.

mikemadison’s picture

We started running into this error on one of our environments and the above patch did help with that error. However, we are now getting this (similar) error:

PHP Fatal error:  Declaration of Drupal\panels\Form\PanelsAddBlockForm::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, ?Symfony\Component\HttpFoundation\Request $request = NULL, $tempstore_id = NULL, $machine_name = NULL, $block_id = NULL) must be compatible with Drupal\panels\Form\PanelsBlockConfigureFormBase::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state, $tempstore_id = NULL, $machine_name = NULL, $block_id = NULL) in /docroot/modules/contrib/panels/src/Form/PanelsAddBlockForm.php on line 14


Error: Declaration of Drupal\panels\Form\PanelsAddBlockForm::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state,
?Symfony\Component\HttpFoundation\Request $request = NULL, $tempstore_id = NULL, $machine_name = NULL, $block_id = NULL) must be
compatible with Drupal\panels\Form\PanelsBlockConfigureFormBase::buildForm(array $form, Drupal\Core\Form\FormStateInterface
$form_state, $tempstore_id = NULL, $machine_name = NULL, $block_id = NULL) in
/docroot/modules/contrib/panels/src/Form/PanelsAddBlockForm.php, line 14
bletch’s picture

We ran into the same problem, it is a PHP version issue. This module throws the error when running PHP v 7.2. We went down to v 7.1 and it fixed the issue.

Is there a plan to roll this patch into the current branch, we prefer to be on 7.2 and this is the only module holding that up for us right now.

guietc’s picture

I prefer to stay in PHP 7.2.
I applied the patch from #2 and it works for me.

mnshantz’s picture

Using PHP7.2 as well and the patch from #2 solved the error for me.

das-peter’s picture

Version: 8.x-1.0-alpha6 » 8.x-1.x-dev
Status: Active » Reviewed & tested by the community

I'd say this is RTBC.
If inheritance is used the child classes should ensure their method signature is compatible with the parents - well before php 7.2 it was considered "should" and just bad style if that wasn't the case - as of php 7.2 it's a "have to" and "you're not allowed to break code by extending" ;).
FieldValidationRuleAddForm and FieldValidationRuleEditForm extend FieldValidationRuleFormBase defines and hence need to support the same arguments in buildForm().
Regarding #4 the "follow-up" error originates in another module with the same problem running on php 7.2.

  • g089h515r806 committed ef9d201 on 8.x-1.x authored by mspae
    Issue #2941006 by mspae: Declaration of (...)FieldValidationRuleAddForm...
g089h515r806’s picture

Status: Reviewed & tested by the community » Fixed

commited

Status: Fixed » Closed (fixed)

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