Problem/Motivation
I got 2 fatal errors with PHP 8.2
TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::buildJquerySelectorForField(): Argument #1 ($field) must be of type array, null given, called in C:\Users\www\web\modules\contrib\conditional_fields\src\ConditionalFieldsFormHelper.php on line 202 in Drupal\conditional_fields\ConditionalFieldsFormHelper->buildJquerySelectorForField() (line 920 of C:\Users\www\web\modules\contrib\conditional_fields\src\ConditionalFieldsFormHelper.php).
TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::elementAddProperty(): Argument #1 ($element) must be of type array, null given, called in C:\Users\www\web\modules\contrib\conditional_fields\src\ConditionalFieldsFormHelper.php on line 197 in Drupal\conditional_fields\ConditionalFieldsFormHelper->elementAddProperty() (line 843 of C:\Users\www\web\modules\contrib\conditional_fields\src\ConditionalFieldsFormHelper.php).
because PHP 8.2 want check type of variable strictement
Steps to reproduce
Proposed resolution
remove array or change to mixed
public function func buildJquerySelectorForField(array $field)
public function elementAddProperty(array $element, $property, $value, $position = 'prepend')
to
public function buildJquerySelectorForField($field)
public function elementAddProperty($element, $property, $value, $position = 'prepend')
Comments
Comment #3
himanshu_jhaloya commentedPatch Failed to Apply. Recreate the new patch Please Review.
Comment #4
himanshu_jhaloya commentedComment #5
dqdThanks for the report and the efforts in here!
But first: Both patches are missing comments/notes/details about what has been changed and why it has been fixed this way. Also what has the second patch done differently?
Apart from that: I decreased the issue priority. Descriptions of the Priority and Status values can be found in the Drupal project issues documentation.
And also, please provide patches and MR always against latest dev. Thanks!
Comment #6
lazzyvn commentedHello,
I'm sorry but I don't know how to report all the information you need.
You can check with php 8.2 required for drupal 10
in node form for example, if you can hook alter form you can add ajax event for field and ajax rebuild the form, then no need to return all elements. that means it will have empty elements. So
php 8.1 below it will not check the variable type in the method but 8.2 will sort the fatal error. For me it is critcal bug because Drupal 10 require php 8.2
I suggest to change to
or
I check the patch it works for the latest branch dev. I will make a merge request if you need it
BTW: Conditional Fields module is very interesting, can you add me as maintainer, i can contribute my time to fix all the errors of phpcs, issue report and validate with gitlab-ci
Comment #7
dqdThanks for coming back and reporting more details! Very much appreciated. Very helpful. And yes a reroll or MR would be very much appreciated! +1
oh and, Sorry but I have to decrease the issue priority. Descriptions of the Priority and Status values can be found in the Drupal project issues documentation.
Thanks for your will to help! We had a co-maintainer request accepted some days ago exactly in the scope of the tasks you describe, thanks, but if we need help, I would love to come back to your offer. +1 Very much appreciated. I have cleaned up the issue queue over the whole weekend with over 200 issues and committed RTBCs and more or less no sleep and plan an upcoming BETA release soon. Stay tuned.
Comment #10
samitk commentedHI @dqd
Reroll and MR created, Please review.
Thanks
Samit K.
Comment #11
heddnThis should have a rebase now that Gitlab CI testing is enabled.
Comment #12
samitk commentedHi @heddn,
Rebased with 4.x, Please review.
Thanks
Samit K.
Comment #15
heddnUnfortunately, I think this needs another rebase. I think the major change here is changing from array => mixed?
Comment #17
andreastkdf commentedJust pushed a reroll.
Comment #18
andreastkdf commentedComment #19
andreastkdf commentedfyi this is now rebased and last commit also includes an additional fix - needs review :)
Comment #20
benstallings commentedI get a merge conflict when I try to rebase on 4.x.
Comment #21
benstallings commentedsince we're now targeting PHP 8.4, I think this ticket is outdated.