Error with PHP 8.2 and field group

Created on 22 February 2024, 11 months ago
Updated 23 February 2024, 11 months ago

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') 
๐Ÿ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance lazzyvn paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @lazzyvn
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 11 months ago
    Patch Failed to Apply
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 11 months ago
    Patch Failed to Apply
  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 11 months ago
    130 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia himanshu_jhaloya Indore

    Patch Failed to Apply. Recreate the new patch Please Review.

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia himanshu_jhaloya Indore
  • Status changed to Postponed: needs info 11 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dqd London | N.Y.C | Paris | Hamburg | Berlin

    Thanks 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!

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance lazzyvn paris

    Hello,
    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

    public function func buildJquerySelectorForField(array $field);
    public function elementAddProperty(array $element, $property, $value, $position = 'prepend');
    

    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

    public function func buildJquerySelectorForField($field)
    public function elementAddProperty($element, $property, $value, $position = 'prepend') 
    

    or

    public function func buildJquerySelectorForField(mixed $field)
    public function elementAddProperty(mixed $element, $property, $value, $position = 'prepend') 
    

    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

  • Status changed to Needs work 11 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dqd London | N.Y.C | Paris | Hamburg | Berlin

    Thanks 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.

    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

    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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    samit.310@gmail.com โ†’ made their first commit to this issueโ€™s fork.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 9 months ago
    130 pass
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    HI @dqd

    Reroll and MR created, Please review.

    Thanks
    Samit K.

  • Status changed to Needs work 6 months ago
  • heddn Nicaragua

    This should have a rebase now that Gitlab CI testing is enabled.

  • Pipeline finished with Success
    6 months ago
    Total: 1532s
    #237079
  • Pipeline finished with Success
    6 months ago
    Total: 1250s
    #237104
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    Hi @heddn,

    Rebased with 4.x, Please review.

    Thanks
    Samit K.

  • Pipeline finished with Success
    6 months ago
    Total: 1024s
    #237135
  • heddn Nicaragua

    Unfortunately, I think this needs another rebase. I think the major change here is changing from array => mixed?

Production build 0.71.5 2024