Problem/Motivation
On PHP 8.4, several functions in field_group declare a typed parameter with a = NULL default but no explicit nullable type. PHP 8.4 deprecates implicitly marking a parameter as nullable, so these emit deprecation warnings, for example:
Drupal\field_group\FormatterHelper::formProcess(): Implicitly marking parameter $form_state as nullable is deprecated, the explicit nullable type must be used instead
Affected signatures:
FormatterHelper::formProcess()($form_state)field_group_form_process()($form_state)field_group_field_group_form_process_build_alter()($form_state)field_group_fields_nest()($vars)field_group_field_layout_fields_nest()($vars)field_group_group_save()($display)
Steps to reproduce
Run field_group on PHP 8.4. Any request or cron run that builds an entity form or display with field groups loads the affected files and triggers the warnings in the logs.
Proposed resolution
Add explicit nullable types (?Type $param = NULL) to the affected parameters. See the change in #6.
Remaining tasks
- Move the patch to a merge request on the issue fork.
- Review/RTBC
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | field_group_8_4.patch | 2.79 KB | didebru |
| field-group-php-8-compatibility.patch | 924 bytes | raphael.badawi |
Issue fork field_group-3317567
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
avpadernoThe issue summary needs to be updated to describe exactly what the bug is.
Comment #4
dineshreddymathuku commentedHi @raphael.badawi did you get any error for PHP 8 compatibility
please provide that error will understand more for that then will do some solution
i saw your patch as well adding (array) problem solved?
Comment #5
swentel commentedTriggered a test on 8.1, let's see how field group behaves on that version.
Comment #6
didebruThere were a few deprecation warnings.
Comment #7
scontzen commentedThanks @didebru for the patch.
Updated the issue summary (re #2) with the actual deprecation messages and the list of affected signatures.
Tested patch #6 (
field_group_8_4.patch) on:Before the patch, loading
FormatterHelperandfield_group.moduleunderE_ALLtriggers the implicitly-nullable deprecation forformProcess()and the procedural functions listed in the summary. With the patch applied, the deprecations are gone. Both files load cleanly underE_ALL,php -lpasses, and the site renders normally. I also checked the module for any other typed parameter with a= NULLdefault but no?, and there aren't any.I'd leave this at Needs work for now. @didebru, would you want to put your change on the issue fork (
3317567-php-8-compatibility) as an MR?Comment #8
scontzen commentedComment #9
avpadernoComment #10
dpiEven though this patch is still relevant for the last 3.x series stable release, a fix was already applied in #3504453: Fix PHP 8.4.x deprecation and other warnings (PHPStan) to 3.x branch, and the 4.x fork.
The maintainers of Field Group have discontinued 3.x entirely, focusing on 4.x being a drop-in replacement.
This issue is no longer required. Is it possible for collaborators (for which I'm not included) on this issue to receive credit? Then feel free to close.
Comment #11
dpiComment #12
anybodyAll new bug fixes and features should go into 4.x-dev first, we can still consider backporting some of them to 8.x-3.x if really needed.
Comment #13
anybodyPlease prepare a MR against 4.x
Comment #14
avpadernoI did not find all the methods/functions listed in the issue summary, but
Formatter::formProcess()seems already fixed.public static function formProcess(array &$element, ?FormStateInterface $form_state = NULL, array &$form = []): array {$form_statehas been explicitly marked nullable.Comment #10 says a fix has been already applied to the 4.x branch.
Comment #15
anybodyThanks @avpaderno so maybe this issue is simply outdated?
Comment #16
avpadernoIt seems it is. The previous comment was stating that and asking for the credits to be given to collaborators.
Comment #17
liam morland